uva 10878 - Decode the tape

 

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


 

 

一开始没思路,只觉得每一行对应一个字符,然后猜测和二进制有点关系但是中间的这个点很不理解干嘛的,

无奈百度之。才知道是assic码,想起大写A的assic码是65。对应的第一行2个0;64+1;原来点是没用的只是分割符而已,

其实每位就是八位的二级制从高到低,用个数组保存下面的重复计算。刚看到一点思路也没有。╮(╯▽╰)╭

#include <stdio.h>
#include <string.h>
void main()
{char s[100];
 int  assic,i,t,bite[10]={128,64,32,16,8,4,2,1};
 while (gets(s))
 {assic=0;
  if (s[0]=='|')
  {for (i=1;i<=5;i++)
   if (s[i]=='o') assic+=bite[i-1];
   for (i=7;i<=9;i++)
   if (s[i]=='o') assic+=bite[i-2];
   printf("%c",assic);
  }
 }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值