Uva 401 - Palindromes
2013-11-26 21:23
369 查看
题目地址http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=342&mosmsg=Submission+received+with+ID+
虽然把代码写完了,也做了很多测试,还是wa,很心痛,有人能帮我看看代码错哪里吗
虽然把代码写完了,也做了很多测试,还是wa,很心痛,有人能帮我看看代码错哪里吗
#include<iostream> #include<string> using namespace std; char ref[100]; void Init(){ ref['A']='A'; ref['E']='3'; ref['H']='H'; ref['I']='I'; ref['J']='L'; ref['L']='J'; ref['M']='M'; ref['O']='O'; ref['S']='2'; ref['T']='T'; ref['U']='U'; ref['V']='V'; ref['W']='W'; ref['X']='X'; ref['Y']='Y'; ref['Z']='5'; ref['0']='O'; ref['1']='1'; ref['2']='S'; ref['3']='E'; ref['5']='Z'; ref['8']='8'; } int IsPalindrome(string s){ int len=s.size(); int i=0,temp; while((temp=(s[i]==s[len-1-i]))&&i<len/2){ i++; } return temp; } int IsMirrore(string s){ int len=s.size(); int i=0,temp; while(i<=len/2){ if(s[i]!=ref[s[len-1-i]]) return 0; i++; } return 2; } int main(){ string annotation[4]={" -- is not a palindrome", //if the string is not a palindrome and is not a mirrored string " -- is a regular palindrome.", //if the string is a palindrome and is not a mirrored string " -- is a mirrored string.", //if the string is not a palindrome and is a mirrored string " -- is a mirrored palindrome."}; //if the string is a palindrome and is a mirrored string string s; Init(); while(cin>>s){ cout<<s<<annotation[IsMirrore(s)+IsPalindrome(s)]<<endl<<endl; } return 0; }
相关文章推荐
- (UVA)401 - Palindromes
- Palindromes UVA - 401
- UVa 401 - Palindromes -AC
- 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
- UVa401 Palindromes
- UVA - 401 Palindromes
- UVa 401 Palindromes(例题3-3)
- UVA401 Palindromes
- UVA 题目401 - Palindromes
- UVa 401:Palindromes