uva401_水题(映射)
2015-08-20 18:12
381 查看
///////////////////////////////////////////////////////////////////////////////////////////////////////
作者:tt2767
声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0
查看本文更新与讨论请点击:http://blog.csdn.net/tt2767
链接被删请百度: CSDN tt2767
///////////////////////////////////////////////////////////////////////////////////////////////////////
原来一直都是一个一个switch来着,这回方便了。。。
作者:tt2767
声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0
查看本文更新与讨论请点击:http://blog.csdn.net/tt2767
链接被删请百度: CSDN tt2767
///////////////////////////////////////////////////////////////////////////////////////////////////////
原来一直都是一个一个switch来着,这回方便了。。。
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> ////////////////////// #include<iostream> #include<algorithm> #include<string> #include <iterator> #include<sstream> #include<functional> #include<numeric> /////////////////////// #include<vector> #include<map> #include <stack> #include<queue> #include<set> #include <bitset> #include <list> using namespace std; #define lch(x) ((x) << 1) #define rch(x) ((x)<<1|1) #define dad(x) ((x)>>1) #define lowbit(x) ((x)&(-x)) typedef long long int LL; const int INF = ~0U>>1; const double eps = 1e-6; const long double PI = acos(0.0) * 2.0; const int N = 10 + 30000; char a ; char s ="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; char h ="A 3 HIL JM O 2TUVWXY51SE Z 8 "; char mp ={0}; bool p(char * x); bool m(char * x); int main() { //ios::sync_with_stdio(false); #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif for(int i = 0 ; i< 35 ; i++) mp[ s[i] ] = h[i]; while(gets(a)) { printf("%s",a); bool x = p(a),y = m(a); if(x && y) puts(" -- is a mirrored palindrome."); else if(!x && !y) puts(" -- is not a palindrome."); else if(x && !y) puts(" -- is a regular palindrome."); else if(y && !x) puts(" -- is a mirrored string."); puts(""); } return 0; } bool p(char * x) { int left = 0 , right = strlen(x)-1; while(left<=right) if(x[left++]!=x[right--]) return 0; return 1; } bool m(char * x) { int left = 0 , right = strlen(x)-1; while(left<=right) if(mp[x[left++]]!=x[right--]) return 0; return 1; }
相关文章推荐
- Android性能优化典范 - 第2季
- 九度 1101 - 字符串处理 - 计算表达式
- 《苏菲的世界》读书笔记
- (转)Java并发编程:深入剖析ThreadLocal
- 9.11排序与查找(四)——20GB的文件,每一行一个字符串,说明如何将这个文件进行排序
- 解决txt导入sql server数据库乱码问题
- MySQL定时器Events
- IOS开源库一览表
- CentOS6 默认源没有tmux的解决办法
- .net验证身份证号是否符合规则
- MySql即使所有地方的编码格式都为utf-8时,为何还是不能正常输入和在cmd下显示
- javascript获取焦点对象ID
- .net验证身份证号是否符合规则
- GSON在项目中的使用
- 1077. Kuchiguse (20)
- addslashes的一些问题
- SQL Server 重置Identity标识列的值(INT爆了)
- 【android学习】更新程序
- 简单工厂模式
- 使用ultraEdit 进行字符串操作技巧