http://poj.org/problem?id=2105
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char str[101]; 6 int pow[8] = {1,2,4,8,16,32,64,128}; 7 int n,t; 8 scanf("%d",&n); 9 while(n--) 10 { 11 int ans = 0; 12 t = 1; 13 scanf("%s",str); 14 int len = strlen(str); 15 for (int i = 0; i < len; i ++) 16 { 17 if(str[i]=='1') 18 { 19 t = i%8; 20 ans+=pow[7-t]; 21 } 22 if((i+1)%8==0) 23 { 24 25 if(i==7) 26 printf("%d",ans); 27 else 28 printf(".%d",ans); 29 ans = 0; 30 } 31 } 32 printf(" "); 33 34 } 35 return 0; 36 }