UVA 401-Palindromes
来源:互联网 发布:linux开机自启动 编辑:程序博客网 时间:2024/05/16 10:02
水题细节也很重要啊。。。
In addition, after each output line, you must print an empty line.
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>typedef long long ll;using namespace std;char const *ch = "AEHIJLMOSTUVWXYZ12358";char const *re = "A3HILJMO2TUVWXY51SEZ8";bool ispalindrome(string s){ int len=s.size(); for(int i=0;i<len/2;i++) if(s[i]!=s[len-i-1]) return false; return true;}bool ismirror(string s){ int len=s.size(); int table_len = strlen(ch); int i,j; if(len == 1) { for( j=0; j<table_len; j++) { if(ch[j] == s[0]) break; } if(j == 21 || re[j] != s[0]) return 0; } else { for(i=0; i<len/2; i++) { for(j=0; j<table_len; j++) { if(ch[j] == s[i]) break; } if(j == 21 || re[j] != s[len-i-1]) return 0; } return 1; }}using namespace std;int main(){ string s; while(cin>>s) { if(ispalindrome(s)) {if(ismirror(s)) {cout<<s<<" -- is a mirrored palindrome.\n"<<endl;continue;} else {cout<<s<<" -- is a regular palindrome.\n"<<endl;continue;}} else { if(ismirror(s)) {cout<<s<<" -- is a mirrored string.\n"<<endl;continue;} else {cout<<s<<" -- is not a palindrome.\n"<<endl;continue;} } } return 0;}
0 0
- UVa 401 Palindromes
- UVa OJ 401-Palindromes
- UVa:401 - Palindromes
- uva 401 Palindromes //字符串
- uva 401 - Palindromes
- UVa 401 - Palindromes
- UVa 401 - Palindromes
- UVa 401 - Palindromes
- uva-401 - Palindromes
- UVa 401 Palindromes
- uva 401 Palindromes
- uva 401 Palindromes
- UVA 401 - Palindromes
- UVa 401 - Palindromes
- UVA 题目401 - Palindromes
- UVA 401 Palindromes
- UVa 401: Palindromes
- UVA 401 Palindromes
- 循环中异常处理机制
- Ubuntu下mysql忘记root密码
- idea14 自定义模板Templates导入
- poj 2531 Network Saboteur(DFS减枝)
- 自定义Label跑马灯
- UVA 401-Palindromes
- Tomcat中采用HTTPS访问
- winform 窗体特效
- 域名解析-DNS-MDNS-LLMNR
- 如何编辑pdf
- 数据结构——堆
- 动态控制html元素显示/隐藏
- iOS-生成国际化包-配置App多语言支持
- C#模拟PrtScn实现截屏预备知识--剪贴板操作