#includestdio.h#includestring.hint main(){char a[40];int n,i,j,z,x;while(scanf("%s",a),strcmp(a,"0")!=0)//输入字符串,如果输入0结束 {n=strlen(a);x=0;z=1;for(i=0;in;i++){z*=2;x+=(a[n-i-1]-'0')*(z-1);}printf("%d\n",x);}return 0;}
#include<stdio.h>
#include<string.h>
int main()
{
char a[40];
int n,i,j,z,x;
while(scanf("%s",a),strcmp(a,"0")!=0)//输入字符串,如果输入0结束
{
n=strlen(a);x=0;z=1;
for(i=0;i<n;i++)
{
z*=2;
x+=(a[n-i-1]-'0')*(z-1);
}
printf("%d\n",x);
}
return 0;
}