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 |
干嘛错啊?样例过了啊,感觉也没什么问题了啊…… #include <iostream> #include <string> #include <stdlib.h> struct node { int w; int index; }key[11]; int cmp(const void *a,const void *b) { struct node *aa=(node *)a; struct node *bb=(node *)b; if(aa->w==bb->w) return 1; else return(aa->w-bb->w); } int main() { char in[200],ans[20]; char out[200][200]; int i,j,k,len,flag,len1; while(scanf("%s",&ans)) { if(strcmp(ans,"THEEND")==0) break; len=strlen(ans); for(i=0;i<len;i++) { key[i].w=(int)(ans[i]-'0'); key[i].index=i+1; } qsort(key,len,sizeof(key[0]),cmp); scanf("%s",&in);flag=0;len1=strlen(in)/len; for(j=0;j<len;j++) { for(k=0;k<len1;k++) { out[k][(key[j].index)-1]=in[flag++]; } } for(i=0;i<len1;i++) for(j=0;j<len;j++) printf("%s",out[i][j]); printf("\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