• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
youdiankun
博客园    首页    新随笔    联系   管理    订阅  订阅

UVA10878 - 详解Decode the tape

 

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.

 

这题一开始总是runtime error,百度后才发现字符每次都要输出……亏我还弄了个数组,最后一起输出。。。

题目大意:

 

 1 #include<stdio.h>
 2 
 3 int main()
 4 {
 5     char s[20];
 6     int i, k, n;
 7     gets(s);
 8     while (gets(s) != 0 && s[0] != '_')   //好久没写了。。
 9     {
10         n = 0;
11         k = 1;
12         for (i = 9; i >= 1; i--)
13         {
14             if (s[i] == 'o')
15                 n += k;
16             if (s[i] != '.')
17                 k *= 2;
18         }
19         printf("%c", n);   //n用int即可输出字母了
20     }
21     return 0;
22 }

2013-09-09

 

 

 

posted @ 2013-09-09 16:53  youdiankun  阅读(310)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3