Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
要考虑某个字母没有逆的情况,这个时候mirro是不存在的。我也在这个地方WA了好几次,后来仔细读题才发现的。In Reply To:WA 的我心都碎了。。。大侠帮帮忙 Posted by:twotwotwo at 2013-02-27 22:24:05 > #include<iostream> > #include<string.h> > #include<stdio.h> > using namespace std; > int main() > { > char str[100]; > string s1="AEHIJLMOSTUVWXYZ12358"; > string s2="A3HILJMO2TUVWXY51SEZ8"; > while(scanf("%s",str)!='EOF') > { > int len=strlen(str); > int i,j; > for(i=0;str[i]==str[len-i-1]&&i<len;i++); > bool palin=false; > bool mirror=true; > if(i==len) > palin=true; > for(i=0;i<len;i++) > { > for(j=0;j<21;j++) > { > if(str[i]==s1[j]) > if(s2[j]==str[len-i-1]) > break; > } > if(j==21) > { > mirror=false; > break; > } > } > cout<<str; > if(palin) > { > if(mirror) > cout<<" -- is a mirrored palindrome."<<endl; > else > cout<<" -- is a regular palindrome."<<endl; > } > else > { > if(mirror) > cout<<" -- is a mirrored string."<<endl; > else > cout<<" -- is not a palindrome."<<endl; > } > cout<<endl; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator