一个挺有意思的字符串水题
//#define LOCAL #include <stdio.h> #include <string.h> #define MAXN 100 + 10 char result[MAXN]; char temp[12]; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif char ascii; int i; while(true) { if(gets(temp) == NULL) break; if(strcmp(temp, "___________") == 0) { ascii = 0; gets(temp); while(strcmp(temp, "___________") != 0) { for(i = 1; i <= 9; i++) { if(temp[i] != '.') { ascii <<= 1; if(temp[i] == 'o') ascii += 1; } } printf("%c", ascii); gets(temp); } } } return 0; }