原文大意:根据所给的数字求出他改变后的状态并输出
解体思路:用数组储存,然后转换成数字,在进行运算
#include<cstdio>
#include<cstring>
int main() {
char num[100];
while(gets(num)) {
int len = strlen(num);
if(len == 1 && num[0] == '0')
break;
int number[100];
int i, j ,k;
for(i = len - 1, j = 0, k = 1; i >= 0; i--, k++,j++){
number[j] = num[i] - '0';
number[j] = number[j] * ((1<<k) - 1);
}
unsigned int n = 0;
for(int l = 0; l < j; l++)
n = n + number[l];
printf("%d\n",n);
}
}