您的位置:首页 > 其它

UVA 10878 - Decode the tape(字符串)

2013-07-24 09:40 417 查看
Decode the tape

Time Limit: 1 second

"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 InputSample 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.

Problemsetter: Igor Naverniouk

Special thanks: BSD games ppt.

=============================

每一行代表一个ascii码,二进制表示,有 "o" 的地方为1,”.“不占二进制的位置不用管

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
char str[20];
while(gets(str))
{
int sum=0;
if(str[0]=='_') continue;
if(str[9]=='o') sum+=1;
if(str[8]=='o') sum+=2;
if(str[7]=='o') sum+=4;
if(str[5]=='o') sum+=8;
if(str[4]=='o') sum+=16;
if(str[3]=='o') sum+=32;
if(str[2]=='o') sum+=64;
if(str[1]=='o') sum+=128;
printf("%c",sum);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: