uva 10878 - Decode the tape

ASCII的问题,注意一行一输出

View Code
 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 int main()
 5 {
 6     char str[15],ex[15];
 7     int len, flag, i, sum, k, h, j;
 8     for(i=0;i<11;i++)
 9     ex[i]='_';
10     ex[i]='\0';
11     gets(str);
12     if(strcmp(str,ex)==0)
13     {
14 
15         while(gets(str) != NULL)
16         {
17             if(strcmp(str,ex)==0)
18             break;
19             sum = 0;
20             j = 7;
21             for(i=0;i<11;i++)
22             {
23                 if(str[i] == 'o')
24                 {
25                     sum+=pow(2,j);
26                     j--;
27                 }
28                 if(str[i] == ' ')
29                 {
30                     j--;
31                 }
32             }
33             printf("%c",sum);
34         }
35     }
36     return 0;
37 }
posted @ 2012-06-04 01:10  琳&leen  阅读(148)  评论(0编辑  收藏  举报