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 |
why wa?#include<iostream> #include<string> using namespace std; string qsort(string a,int b) { int i,j; char temp; for(i=0;i<b-1;i++) for(j=0;j<b-i-1;j++) if(a[j]>a[j+1]) {temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } return a; } int main() { string x,y,m,n; char z[110]; int i; int j; int k=0,t=0,r; cin>>x; cin>>y; if(x.size()!=y.size()) cout<<"NO"<<endl; else { for(i=1;i<=26;i++) { t++; for(j=0;j<y.size();j++) { if('Z'-y[j]>=i) z[j]=y[j]+i; else z[j]=y[j]+i-26; } m=qsort(z,y.size()); n=qsort(x,x.size()); for(r=0;r<x.size();r++) if(m[r]==n[r]&&m[r]>='A'&&m[r]<='Z'&&n[r]>='A'&&n[r]<='Z') k++; if(k==x.size()) {cout<<"YES"<<endl;break;} if(k!=x.size()&&t==26) {cout<<"NO"<<endl;break;} k=0; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator