UVA10878 Decode the tape

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1819

这个题找到规律就很好做,就是相当于二进制,o代表1,空格代表0,然后算出来为字母的ASCII码,输出就行了。

View Code
 1 #include <stdio.h>
 2 #include <math.h>
 3 #include<string.h>
 4 int main()
 5 {
 6     int i,j,k;
 7     char c[20];
 8     gets(c);
 9     while(gets(c)!=NULL)
10     {
11         if(strcmp(c,"___________")==0)
12         break;
13         k = 0;
14         for(i=9 ; i > 0  ;i--)
15         {
16             if(c[i]=='o')
17             {
18                 if(i<7)
19                 k+=pow(2,8-i);
20                 else
21                 k+=pow(2,9-i);
22             }
23         }
24         printf("%c", k);
25     }
26     return 0;
27 }
原文地址:https://www.cnblogs.com/shangyu/p/2533519.html