Decode the tape
2015-07-26 10:12
399 查看
Description
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
Sample Output
代码:
"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
___________ | 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; }
相关文章推荐
- Android_Audio_Omap_HAL
- Xcode6.4中,第三方插件无法使用的解决方法
- 学习C++的感想
- 如何查看树莓派的DNS
- HDU 5305 Friends
- Asteroids - poj 3041(二分图最大匹配问题)
- Linux中TTY是什么意思
- 菜鸟初行---HelloWorld
- [C++学习笔记]--动态分配内存空间
- 北海道中文离线地图App上线
- 独木舟上的旅行
- 鼠标经过子元素触发mouseout,mouseover事件的解决方案
- Start cluster zookeeper in shell script
- TCP编程,Socket通讯
- linux C中调用shell命令和运行shell脚本
- 8,计时器应用实例
- poj 2886 Who Gets the Most Candies? (树状数组+二分+反素数)
- cf558c(bfs)
- http代理
- http压缩