一个挺有意思的字符串水题
//#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;
}
本文介绍了一个有趣的字符串处理问题:如何从一种特殊格式的输入中解析并转换成ASCII字符。通过逐行读取输入,并根据特定规则解析每行数据,最终实现将输入数据转换为相应的ASCII字符序列。
1363

被折叠的 条评论
为什么被折叠?



