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 |
排序然后一一比较怎么wa了?#include<iostream> #include<string.h> using namespace std; char a[200],b[200],x[200],y[200]; int main() { int i,j,m,k; gets(a); gets(b); m=strlen(a); for(i=0;i<m;i++) { char r='z'; for(j=0;j<m;j++) { if(r>=a[j]) { r=a[j]; k=j; } } x[i]=a[k]; a[k]='z'; } for(i=0;i<m;i++) { char r='z'; for(j=0;j<m;j++) { if(r>=b[j]) { r=b[j]; k=j; } } y[i]=b[k]; b[k]='z'; } puts(x); puts(y); int tmp=1; int s=x[0]-y[0]; for(i=1;i<m;i++) { if(x[i]-y[i]!=s) { tmp=0; break; } } if(tmp==1) cout<<"YES"; else cout<<"NO"; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator