UVa10878 - Decode the tape-字符串-难度1
2013-12-23 13:04
441 查看
题目链接:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1819
Problem A
Decode the tape
Time Limit: 1 second
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.
Problemsetter: Igor Naverniouk
Special thanks: BSD games ppt.
代码+思路:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1819
Problem A
Decode the tape
Time Limit: 1 second
"Machines take me by surprise with great frequency." |
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. |
Special thanks: BSD games ppt.
代码+思路:
/* *主要是理解题意: *去除'.',其余7位组成ASCII码,'o'表示对应位是1 */ #include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; const int MAX = 101; char ans[MAX][MAX]; int main() { #ifdef LOCAL freopen("f:\\input.txt", "r", stdin); //freopen("f:\\output.txt", "w", stdout); #endif string s; int first = 0; while(getline(cin, s)) { if(s[0] == '_') { if(first == 1) { cout << endl; break; } else { continue; } } int sum = 0; int time = 1; for(int i = 9; i != 1; i--) { if(s[i] == 'o') { sum += time; } if(s[i] != '.')//如果是'.', 跳过这位 time = 2 * time; } printf("%c", sum); } return 0; }
相关文章推荐
- UVA 10878 (暑假-字符串(2) -C - Decode the tape)
- UVA 10878 - Decode the tape(字符串)
- uva 10878 Decode the tape(字符串处理)
- uva 10878 - Decode the tape
- UVa-10878-Decode the tape
- uva - 10878 - Decode the tape
- UVa 10878 - Decode the tape
- UVA之10878 - Decode the tape
- UVA-10878 Decode the tape
- UVA10878 - 详解Decode the tape
- UVa 10878 - Decode the tape 解题报告
- UVa-10878-Decode the tape
- UVA - 10878 Decode the tape
- UVA 10878 Decode the tape
- UVA - 10878 Decode the tape
- uva 10878 Decode the tape
- UVa 10878 Decode the tape
- UVA10878 Decode the tape【编码】
- UVA 10878 Decode the tape
- UVa 10878 - Decode the tape