10878 - Decode the tape
Time limit: 3.000 seconds
| "Machines take me by surprise with great frequency." |
Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them.
Input
The input will contain one tape.
Output
Output the message that is written on the tape.
| Sample Input | Sample Output |
___________ | o . o| | o . | | ooo . o| | ooo .o o| | oo o. o| | oo . oo| | oo o. oo| | o . | | oo . o | | ooo . o | | oo o.ooo| | ooo .ooo| | oo o.oo | | o . | | oo .oo | | oo o.ooo| | oooo. | | o . | | oo o. o | | ooo .o o| | oo o.o o| | ooo . | | ooo . oo| | o . | | oo o.ooo| | ooo .oo | | oo .o o| | ooo . o | | o . | | ooo .o | | oo o. | | oo .o o| | o . | | oo o.o | | oo . o| | oooo. o | | oooo. o| | o . | | oo .o | | oo o.ooo| | oo .ooo| | o o.oo | | o. o | ___________ | A quick brown fox jumps over the lazy dog. |
多看看磁带吧。
完整代码:
#include<cstdio>
#include<cstdlib>
char str[11], num[8], *endstr;
int main(void)
{
gets(str);
while (gets(str), str[1] != '_')
{
int i;
for (i = 2; i <= 5; ++i)
num[i - 2] = (str[i] == 'o' ? '1' : '0');
for (i = 7; i <= 9; ++i)
num[i - 3] = (str[i] == 'o' ? '1' : '0');
num[7] = '\0';
putchar(strtol(num, &endstr, 2));
}
return 0;
}

本文介绍了一个关于解码旧计算机磁带上信息的问题。输入包含一盘磁带,上面通过排列的孔来表示信息,需要输出磁带上记录的消息。示例展示了如何将特定的孔洞模式转换为文本字符。
19万+

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



