Topic Description:
Enter a binary number, ending with a carriage return. The binary number is a positive number, length is not more than 31.
输出
输出一个整数,为该二进制数对应的十进制数。
样例输入 Copy
100000000001
样例输出 Copy
2049
# include<stdio.h>
int main()
{
int n=0;
char m;
while((m=getchar())!='\n')
{
n=n*2+(m-'0');
}
printf("%d",n);
return 0;
}
Note: m as a character instead of a number, m should subtract 0 corresponding ascii code will correspond.