Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by qwertyuil,mnbvcxcv bn ( 15 years ago )
#include <stdio.h>
#include <stdlib.h>
void delsp(char* s,int *n)
{ int i,d=0;
for(i=0,i<n,i++)
{ s[i-d]=s[i];
if (s[i]==' ')
d++;
}
n=n-d;
}
int parse_number(const char *s, int b, int *is_ok)
{ int x=0,i=0 sign=1;
char c;
if (s[i]=='-')
{ i++
sing=-1;
}
if (s[i]=='+')
i++
if (b<=10)
while(s[i]>='0' && s[i]<='(char)(b-1)')
{ x=x*b+(int)s[i];
i++;
}
else
{ c=(char)(b-10+int('a'))
while((s[i]>='0' && s[i]<='9') || (s[i]>='a' && s[i]<=c))
{ if (s[i]>='0' && s[i]<='9')
x=x*b+(int)s[i];
else
x=x*b+(int)s[i]-((int)'a')+10;
i++;
}
}
return x*sign;
}
int main()
{ int n,b,x;
bulit is_ok;
char *s;
printf("long str");
scanf("%d",n);
s=calloc(n+1,sizeof(char));
// for (b=0;b<=n;n++)
// s[b]='\n';
printf("str");
fflush();
scanf("%s",s);
printf("base");
scanf("%d",b);
delsp(s,&n);
x=parse_number(s,b,&is;_ok);
printf("%d",x);
free(s);
return 0;
}
Revise this Paste