码迷,mamicode.com
首页 > 其他好文 > 详细

UVa 10878 Decode the tape

时间:2014-07-01 18:59:00      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   strong   width   

题目很简单,代码也很短。第一遍做的时候,我居然二乎乎的把input里面的小框框忽略掉了,所以WA了一次。

每一行代表一个二进制的ASCII码,‘o‘代表1,空格代表0,中间的小黑点忽略。

我直接把一行字符串全读进去,如果字符串以下划线开头说明输入结束(字符串的处理从第2行开始)。

然后从左到右一个字符一个字符的判断,是空格直接*2,是‘o‘先*2后加1,最后算出的就是对应的ASCII值。

 

Problem A
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 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.

 


Problemsetter: Igor Naverniouk
Special thanks: BSD games ppt.

bubuko.com,布布扣
 1 //#define LOCAL
 2 #include <iostream>
 3 #include <cstring>
 4 #include <cstdio>
 5 using namespace std;
 6 
 7 int main(void)
 8 {
 9     #ifdef LOCAL
10         freopen("10878in.txt", "r", stdin);
11     #endif
12     int i;
13     char str[15], ascii;
14     gets(str);
15     while(gets(str) && str[0] != _)
16     {
17         ascii = 0;
18         for(i = 0; i < strlen(str); ++i)
19         {
20             if(str[i] ==  )
21                 ascii *= 2;
22             if(str[i] == o)
23             {
24                 ascii *= 2;
25                 ascii += 1;
26             }
27         }
28         printf("%c", ascii);
29     }
30     return 0;
31 }
代码君

 

UVa 10878 Decode the tape,布布扣,bubuko.com

UVa 10878 Decode the tape

标签:style   blog   http   color   strong   width   

原文地址:http://www.cnblogs.com/AOQNRMGYXLMV/p/3817630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!