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 "stdio.h" #include "string.h" #include "stdlib.h" int cmp(const void *a,const void *b) {return *(char *)a-*(char *)b;} void main() { char a[202],change; int i,j; int l,c; gets(a); //scanf("%s",a); l=strlen(a); qsort(a,l,sizeof(a[0]),cmp); a[l]='\0'; printf("%s\n",a); i=l-1;c=1; while(1) { for(j=i;j>=0;j--) { if(a[i]>a[j]) { change=a[i]; a[i]=a[j]; a[j]=change; break; } } if(l-1-c==-1) break; if(j<0) { i=l-1-c; c++; continue; } c=1; i=l-1; qsort(a+j+1,l-j-1,sizeof(a[0]),cmp); a[l]='\0'; printf("%s\n",a); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator