您的位置:首页 > 其它

UVA 10878 Decode the tape

2013-07-24 23:20 489 查看

UVA 10878 Decode the tape

只要找出规律就很水。。。其实就是ASCALL码。空格代表0,‘o'代表1,的二进制表示的ASCALL码。
然后输出就可以了

#include <stdio.h>
#include <string.h>

char a[105];
int sb[10];
int main()
{
sb[1] = 128;
sb[2] = 64;
sb[3] = 32;
sb[4] = 16;
sb[5] = 8;
sb[7] = 4;
sb[8] = 2;
sb[9] = 1;
while (gets(a) != NULL)
{
if (a[0] == '|')
{
int num = 0;
for (int i = 1; i < strlen(a) - 1; i ++)
{
if(a[i] == 'o')
num += sb[i];
}
printf("%c", num);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: