poj1298 The Hardest Problem Ever ——水题
2013-04-19 14:18
260 查看
题目链接:http://poj.org/problem?id=1298
题目大意:
字母映射。太简单了。不说了。感脚都不好意思在博客里面写……水题一次最多切3道,再多就没意思了……也没有意义……
题目思路:
为了学习STL,用的map。
在OJ上看到了自己以前写的代码,感脚好精简~
原来自己以前的代码风格曾经这么精悍,哈哈
题目大意:
字母映射。太简单了。不说了。感脚都不好意思在博客里面写……水题一次最多切3道,再多就没意思了……也没有意义……
题目思路:
为了学习STL,用的map。
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <set> #include <map> #include <vector> #include <stack> #include <queue> #include <cmath> #include <algorithm> #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 using namespace std; typedef long long int LL; const int MAXN = 0x3f3f3f3f; const int MIN = -0x3f3f3f3f; const double eps = 1e-9; const int dir[8][2] = {{0,1},{1,0},{0,-1},{-1,0},{-1,1}, {1,1},{1,-1},{-1,-1}}; map<char, char> mymap; string a, b, c; char aa[10000]; int main(void){ #ifndef ONLINE_JUDGE freopen("1298.in", "r", stdin); #endif for (int i = 0; i < 26; ++i){ if (i <= 4) mymap[i+'A'] = 'A' + 21 + i; else mymap[i+'A'] = i +'A'-5; } while (cin >> a){ if (a == "ENDOFINPUT") break; getchar(); gets(aa); int len = strlen(aa); for (int i = 0; i < len; ++i){ if (isalpha(aa[i])){ printf("%c", mymap[aa[i]]); } else printf("%c", aa[i]); } printf("\n"); cin >> b; } return 0; }
在OJ上看到了自己以前写的代码,感脚好精简~
# include <stdio.h> # include <string.h> char a[201]; int main(void) { char endall[] = "ENDOFINPUT"; char start[10]; /* = "START"; */ char end[4]; /* = "END"; */ int n = 101; int i; char c; while (n--) { scanf("%s", start); if (strcmp(start, endall) == 0) break; i = 0; getchar(); while ((c = getchar()) != '\n') { a[i] = c; i++; } a[i] = '\0'; for (i = 0; i < strlen(a); i++) { if (a[i] >= 'A' && a[i] <= 'E') a[i] = a[i] + 21; else if (a[i] >= 'F' && a[i] <= 'Z') a[i] = a[i] - 5; } printf("%s\n", a); scanf("%s", end); } return 0; }
原来自己以前的代码风格曾经这么精悍,哈哈
相关文章推荐
- POJ 1298 The Hardest Problem Ever(我的水题之路——解密,水题)
- hdu_1048_The Hardest Problem Ever_字符输入输出问题水题一道
- POJ1298_The Hardest Problem Ever_最难的问题_Caesar 密码_C++
- hdoj 1048 the hardest problem ever (水题)
- HDU ACM 1048 The Hardest Problem Ever (水题)
- poj1298 The Hardest Problem Ever
- The Hardest Problem Ever - POJ 1298 水题
- The Hardest Problem Ever【字符串处理 水题】
- Poj1298_The Hardest Problem Ever(水题)
- Poj1298_The Hardest Problem Ever(水题)
- hdu 1048 The Hardest Problem Ever(水题)
- POJ1298 The Hardest Problem Ever
- The Hardest Problem Ever(hdu1048字符串水题)
- Poj1298_The Hardest Problem Ever(水题)
- HDOJ 1048 The Hardest Problem Ever(加密解密类)
- POJ1298 The Hardest Problem Ever
- HDOJ 1048 The Hardest Problem Ever
- 1048 The Hardest Problem Ever
- poj 1298 The Hardest Problem Ever
- HDU 1048 The Hardest Problem Ever