10878-decode the tape
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem &problem=1819
"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. It falls to the figure out what are written on them.
Input the input would contain one tape.
Output output The message this is written on the tape.
___________
| 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 | |
o| |
oo o.o o| |-ooo oo| | o . |
| oo o.ooo|
| ooo oo |
| oo . o o| |
ooo o | | o . |
| | ooo. 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 |
___________
Look at the tapes more.
Complete code:
#include <cstdio>
#include <cstdlib>
char str[11], num[8], *endstr;
int main (void)
{
gets (str);
while (gets (str), str[1]!= ' _ ')
{
int i;
for (i = 2; I <= 5; ++i)
num[i-2] = (str[i] = = ' o '? ' 1 ': ' 0 ');
for (i = 7; I <= 9; ++i)
num[i-3] = (str[i] = = ' o '? ' 1 ': ' 0 ');
NUM[7] = ' the ';
Putchar (Strtol (num, &ENDSTR, 2));
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/