Vomume 1.Elementary Problem Solving->volume 1 string 401-Palindromes
来源:互联网 发布:udid代理系统源码 编辑:程序博客网 时间:2024/06/09 13:53
401-Palindromes(原题的连接)
这个题是我做UVA以来第一次1A.
#include<iostream>#include<string>using namespace std;int main(){ string s,s1,s2; char c; int len,i,f1,f2,f3; while(cin>>s) { s1=s2=s; len=s.size(); for(i=0;i<len/2;i++) { c=s[i]; s[i]=s[len-1-i]; s[len-1-i]=c; } if(s1==s) f1=1; else f1=0; f3=0; s1=s; for(i=0;i<len;i++) { switch(s[i]) { case 'B':f3=1;break; case 'C':f3=1;break; case 'D':f3=1;break; case 'F':f3=1;break; case 'G':f3=1;break; case 'K':f3=1;break; case 'N':f3=1;break; case 'P':f3=1;break; case 'Q':f3=1;break; case 'R':f3=1;break; case '4':f3=1;break; case '6':f3=1;break; case '7':f3=1;break; case '9':f3=1;break; } if(f3) { f2=0; break; } else { f2=1; if(s[i]=='E') s[i]='3'; else if(s[i]=='J') s[i]='L'; else if(s[i]=='L') s[i]='J'; else if(s[i]=='S') s[i]='2'; else if(s[i]=='Z') s[i]='5'; else if(s[i]=='2') s[i]='S'; else if(s[i]=='3') s[i]='E'; else if(s[i]=='5') s[i]='Z'; } } if(f2==1) { for(i=0;i<len/2;i++) { c=s[i]; s[i]=s[len-1-i]; s[len-1-i]=c; } if(s1==s) f2=1; else f2=0; } if(f1==0&&f2==0) { cout<<s2<<" -- is not a palindrome."; cout<<endl; } else if(f1==1&&f2==0) { cout<<s2<<" -- is a regular palindrome."; cout<<endl; } else if(f1==0&&f2==1) { cout<<s2<<" -- is a mirrored string."; cout<<endl; } else { cout<<s2<<" -- is a mirrored palindrome."; cout<<endl; } cout<<endl; } return 0;}
- Vomume 1.Elementary Problem Solving->volume 1 string 401-Palindromes
- UVa Volume 1. Elementary Problem Solving :: String
- Volume 1. Elementary Problem Solving->Volume 1 String 409 - Excuses, Excuses!
- Volume 1. Elementary Problem Solving->Volume 1 String 10115 - Automatic Editing
- Volume 1. Elementary Problem Solving :: String Uva 401,10010,10361,537,409
- 【索引】Volume 1. Elementary Problem Solving
- 【索引】Volume 1. Elementary Problem Solving
- [索引] Volume 1. Elementary Problem Solving
- 【索引】Volume 1. Elementary Problem Solving
- [索引] Volume 1. Elementary Problem Solving
- 【索引】Volume 1. Elementary Problem Solving
- 【索引】Volume 1. Elementary Problem Solving
- 【索引】Volume 1. Elementary Problem Solving
- uva算法入门经典题解导航 - Volume 1. Elementary Problem Solving - String
- OVa Online Judge 学习笔记- AOAPC I Volume 1. Elementary Problem Solving String
- Volume 1. Elementary Problem Solving->Volume 2 Big Number 10106 - Product
- uva算法入门经典题解导航 - Volume 1. Elementary Problem Solving
- uva算法入门经典题解导航 - Volume 1. Elementary Problem Solving - Sorting/Searching
- html复习
- 有关servlet
- cocos2d-x的中文编码问题解决方案
- JDBC
- 有关域名的种种
- Vomume 1.Elementary Problem Solving->volume 1 string 401-Palindromes
- JDBC连接MySQL
- servlet
- JSP/Servlet转发与重定向的区别
- Java学习之Servlet原理(收集)
- Java Servlet技术
- 黑马程序员_交通灯管理系统笔记
- 正则应用
- 掌握什么电子知识,大学阶段如何学习?