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;
}