开始以为统计示例那句话中26个字母对应的字符串就行了,后来发现‘A’和‘a’不一样,仔细一看有一个位不一样,突然想到了ascii,一看7位,这不正好吗!
1 # include <stdio.h>
2 # include <string.h>
3
4 char str[15];
5 char t[8] = {64, 32, 16, 8, 0, 4, 2, 1};
6
7 int main()
8 {
9 short int i, c;
10
11 gets(str);
12 while (gets(str) != NULL)
13 {
14 c = 0;
15 for (i = 2; i <= 9; ++i)
16 if (str[i] == 'o') c += t[i-2];
17 if (c != 0) putchar(c);
18 }
19
20 return 0;
21 }
/* */