uva575 Skew Binary
水题,不解释!
View Code
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char s[100]; 6 while(scanf("%s",s) && s[0] != '0') 7 { 8 int temp = 2, sum = 0, k, i; 9 k = strlen(s); 10 for(i = k-1;i >= 0; i--) 11 { 12 sum += (s[i]-'0')*(temp-1); 13 temp *= 2; 14 } 15 printf("%d\n",sum); 16 } 17 return 0; 18 }