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 |
我晕,为什么YES可以就继续输入数据,NO就测试结束?附代码我把别人的输出代码替代我的就AC了,但我就不明白了,题目也没这么别扭的输出要求啊,坑爹啊?! 注释的是我自己写的输出。WA死我了。 #include <iostream> #include <string.h> #include <stdlib.h> using namespace std; int cmp(const void *a,const void *b) {return *(int *)b - *(int *)a;} int main() { int a[27],b[27],i,len1,len2,flag; char ch1[150],ch2[150]; while(scanf("%s",ch1)!=EOF) { scanf("%s",ch2); flag=0;len1=strlen(ch1);len2=strlen(ch2); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=0;i<len1;i++) a[ch1[i]-'A']++; for(i=0;i<len2;i++) b[ch2[i]-'A']++; qsort(a,27,sizeof(a[0]),cmp); qsort(b,27,sizeof(b[0]),cmp); /*for(i=0;i<26;i++) if(a[i]!=b[i]) break; if(i==26) printf("YES\n"); else printf("N0\n");*/ for(i=0;i<26;i++) if(a[i]!=b[i]) { printf("NO\n"); return 0; } printf("YES\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator