开始的时候没看懂,然后看到空格和o时就想到了——很久很久以前输入指令要:打孔。
然后就简单了。。。
这也是我在UVa上见到的题目最短的题了。。。
代码如下:
1 #include<stdio.h> 2 #include<string.h> 3 int a[11]={0, 128,64,32,16,8,0,4,2,1}; 4 int main() 5 { 6 int i, n, b; 7 char str[20]; 8 while(gets(str)) 9 { 10 if (str[0] != '|') 11 continue; 12 b=0; 13 n=strlen(str); 14 for (i=1; i<=9; i++) 15 { 16 if (str[i]== '.')continue; 17 if (str[i] == 'o') 18 { 19 b+=a[i]; 20 } 21 } 22 printf("%c", b); 23 } 24 return 0; 25 }