例题3-3 回文词(Palindromes)
来源:互联网 发布:信用卡淘宝套现技巧 编辑:程序博客网 时间:2024/05/20 14:41
#include <iostream>#include <string.h>#include <stdio.h>#include <ctype.h>const char* rev="A 3 HIL JM O 2TUVWXY51SE Z 8 ";const char* msg[]={"not a palindrome","a regular palindrome","a mirrored string","a mirrored palindrome"};char r(char ch){ if(isalpha(ch)) return rev[ch-'A']; return rev[ch-'0'+25];}using namespace std;int main(){ char s[30]; while(scanf("%s",s)!=EOF) { int len=strlen(s); int p=1,m=1; for(int i=0;i<(len+1)/2;i++) { if(s[i]!=s[len-1-i]) p=0; if(r(s[i])!=s[len-1-i]) m=0; } printf("%s -- is %s.\n\n",s,msg[m*2+p]); } return 0;}
/*注意 char* 相当于一维数组 char*[] 相当于二维数组(每个引号间的内容相当于一行 char[][]取一行中的一个字符) 此题还得参考书上的镜面表 isalpha的头文件是 ctype.h*/
0 0
- 例题3-3 回文词(Palindromes)
- 《算法竞赛入门经典2ndEdition 》例题3-3 回文词(Palindromes, Uva401)
- 例题3-3 回文词 UVa401
- UVa 401 Palindromes(例题3-3)
- 3-3 回文词(Palindromes P48) / HIT
- 例题3-3回文词镜像词
- 章三例题3——UVA 401 Palindromes
- 字符串与数组03-例题3 Palindromes,UVa401
- 小白书 3.3 例题3-4回文串
- 例题3-4 最长回文子串
- UVa 401 - Palindromes(回文词)
- 回文词(401 - Palindromes)
- UVA 401 Palindromes 回文词
- UVA 401 Palindromes 回文词
- UVA 401 Palindromes(回文词)
- 回文词(Palindromes, UVa401)
- 回文词(Palindromes, UVa401)
- 回文词(Palindromes,UVa401)
- 离线搭建 Android 集成开发环境
- poj 1945 Power Hungry Cows(BFS)(简单题)
- error: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) Unable t
- REST HTTP中的POST PUT GET
- 人丑就要多读书(11)
- 例题3-3 回文词(Palindromes)
- 文字信息间歇性滚动效果
- C#中加载dll的问题
- AD 组策略
- 课程设计
- [LeetCode]First Missing Positive(!!!)
- 编程语言的本质:1.编程语言的计算能力
- Lucene.Net 与 盘古分词
- Combination Lock 号码锁 From USACO