UVA - 10878 Decode the tape

Description

 

"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

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

Sample Output

A quick brown fox jumps over the lazy dog.
题意:观察题,空格代表二进制的0,‘o’代表1
思路:处理输出
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;

int f[11] = {0,0,64,32,16,8,0,4,2,1,0};  

int main() {
	char str[12];
	gets(str);
	while (gets(str) && str[0] != '_') {
		int ans = 0;
		for (int i = 2; i < 10; i++)
			if (str[i] == 'o')
				ans += f[i];
		printf("%c", ans);
	}
	return 0;
}


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