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 |
Re:请大家帮忙看看2159得思路In Reply To:请大家帮忙看看2159得思路 Posted by:dancia at 2005-04-02 12:24:39 > 这道题我想得很简单,就是把message2按照加密方式加密一次得到message3, > 然后将message1和message3都按字典序排列后比较。一样就yes,不然就no。这 > 样有什么问题啊?哪位老大给组测试数据,谢谢 > > #include <stdio.h> > #include <string.h> > #include <stdlib.h> > > char a[110],b[110]; > char book[27]={"BCDEFGHIJKLMNOPQRSTUVWXYZA"}; > int cmp(const void *a,const void *b) > { char c=*((char*)a); > char d=*((char*)b); > return c-d; > } > > main() > { > int i,j; > gets(a); > gets(b); > for(i=0;i<strlen(b);i++) > b[i]= book[b[i]-'A']; > qsort(a,strlen(a),sizeof(char),cmp); > qsort(b,strlen(b),sizeof(char),cmp); > (!strcmp(a,b))?printf("YES"):printf("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