Welcome

首页 / 软件开发 / 数据结构与算法 / UVa 10878 Decode the tape:趣题

UVa 10878 Decode the tape:趣题2014-07-20 csdn博客 synapse710878 - 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 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.

___________| 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 |___________
多看看磁带吧。

完整代码:

#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] = "";putchar(strtol(num, &endstr, 2));}return 0;}