Description
Input
The input will contain one tape.
Output
Output the message that is written on the tape.
Sample Input
___________ | 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 | ___________
Sample Output
A quick brown fox jumps over the lazy dog.
大意:
'o' --> '1' ' ' --> '0' 将每一行的ASCII码转换为字符后输出
要点:
不能使用数组来存取结果
读取一行输出一次
代码:
#include <iostream>
#include <string>
using namespace std;
int c[] = { 0, 0, 64, 32, 16, 8, 0, 4, 2, 1, 0 };
int main()
{
char asc;
string str;
int count = 0;
getline(cin, str);
while (getline(cin, str))
{
asc = 0;
if (str[0] == '_')
break;
if (str[0] == '|')
for (int i = 0; i < 10; i++)
{
if (str[i] == 'o')
asc += c[i];
}
cout << asc;
}
return 0;
}