#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
char ch[10009];
int len,i,b,num,k;
int binary_to_int(char ch[])
{
len = strlen(ch);
k=0; b=0;
for(i=len-1;i>=0;i--)
{
b=b+(ch[i]-48)*(int)pow(2,k++);
}
return b;
}
int main()
{
while(scanf("%s",ch)==1)
{
num = binary_to_int(ch);
printf("%d\n",num);
}
return 0;
}
No comments:
Post a Comment