Time Limit: 1 second
"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. |
题目大意:题意很重要,每一行对应一个字符,o带表1,其他符号代表0,组成的字符的ASCLL码。
解题思路:每读取一行数据,对数据进行处理输出字符。(注意‘|’要处理)
#include<stdio.h>
#define N 12
int find(int k)
{
switch(k)
{
case 1:
return 128;
case 2:
return 64;
case 3:
return 32;
case 4:
return 16;
case 5:
return 8;
case 7:
return 4;
case 8:
return 2;
case 9:
return 1;
default:
return 0;
}
}
int main()
{
char str[N];
while (gets(str) != NULL)
{
if (str[0] != '|')
continue;
int sum = 0;
for (int i = 1; i < N; i++)
if (str[i] == 'o')
sum +=find(i);
putchar(sum);
}
return 0;
}