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

 

 

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

无奈百度之。才知道是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);
  }
 }
}

 

你可能感兴趣的:(uva 10878 - Decode the tape)