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 <stdio.h> #include <math.h> #include <string.h> main() { int i,j=0,k,n,m,y,c[100],h,d[100],e[100]; char a[100][100]={0},b[100][100]={0},x; scanf("%d",&n); scanf("%d ",&m); h=n; for(i=0;i<m;i++) { gets(a[i]); strcpy(b[i],a[i]); } for(k=0;k<m;k++) { y=0; n=h; for(j=0;j<(n-1);j++) { for(i=0;i<n;i++) { if((b[k][i]-b[k][i+1])>0) { x=b[k][i]; b[k][i]=b[k][i+1]; b[k][i+1]=x; y++; } } n--; } c[k]=y; } for(i=0;i<m;i++) d[i]=c[i]; for(j=0;j<m;j++) { for(i=j+1;i<m;i++) if(d[j]>d[i]) { x=d[j]; d[j]=d[i]; d[i]=x; } } for(i=0;i<m;i++) { for(j=0;j<m;j++) { if(d[i]==c[j]) e[i]=j; } } printf("\n"); for(i=0;i<m;i++) { for(j=0;j<h;j++) printf("%c",a[e[i]][j]); printf("\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator