uva 10878 Decode the tape (简单题)
2013-09-14 20:28
393 查看
由于uva访问对浏览器要求。所以这里uva的题目就不再开设快速访问链接~
说下这个题。这个题很有趣,没有告诉你任何数据,只是说告诉你一条磁带让你来解码。然后,就没有然后了。。。。。。
观察这个磁带跟对已的一段string。会发现'o'这个字符出线的位置都一直是固定的,总共出线在7个位置,二进制的7位有128种情况,一次对应的即是ascll表。所以,每一行'o'字符出现表示1,没有出现表示0。注意,仅是'o'字符出现的7个位置,其余位置的字符全部认为为0,这样每行对应的二进制数所对应的ascll即为最后所得到的string。
实现看代码
说下这个题。这个题很有趣,没有告诉你任何数据,只是说告诉你一条磁带让你来解码。然后,就没有然后了。。。。。。
观察这个磁带跟对已的一段string。会发现'o'这个字符出线的位置都一直是固定的,总共出线在7个位置,二进制的7位有128种情况,一次对应的即是ascll表。所以,每一行'o'字符出现表示1,没有出现表示0。注意,仅是'o'字符出现的7个位置,其余位置的字符全部认为为0,这样每行对应的二进制数所对应的ascll即为最后所得到的string。
实现看代码
#include<cstdio> #include<iostream> using namespace std; int c[] = {0,0,64,32,16,8,0,4,2,1,0}; int main() { #ifdef LOCAL freopen("in.txt","r",stdin); #endif // LOCAL char str[45]; gets(str); while(gets(str) && str[0] != '_') { int value = 0; for(int i = 2 ; str[i] != '\0' ; i++) { if(str[i] == 'o') { value += c[i]; } } printf("%c",value); } return 0; }
相关文章推荐
- UVa 10878 Decode the tape
- UVA 10878 - Decode the tape
- UVa-10878-Decode the tape
- 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
- 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