您的位置:首页 > 其它

Decode the tape

2015-07-26 10:12 399 查看
Description

 
"Machines take me by surprise with great frequency."
Alan Turing

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

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



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: