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" main() { long int n,m,k,i,j,sum[100]; char a[100][50],c,temp[100][50]; scanf("%d%d",&n,&m); scanf("%c",&c); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%c",&a[i][j]); scanf("%c",c); } for(i=0;i<=m-1;i++) for(j=0;j<=n-1;j++) for(k=1;k<n-j;k++) if ( a[i][j]>a[i][j+k]) sum[i]++; for (i=0;i<=m-1;i++) { i=k; for (j=i+1;j<=m-1;j++) if (sum[k]<sum[j]) k=j; if (i!=k) { for (j=0;j<=n-1;j++) { temp[i][j]=a[i][j]; a[i][j]=a[k][j]; a[k][j]=temp[i][j]; } } } for (i=0;i<m;i++) { for (j=0;j<n;j++) printf("%c",a[i][j]); printf("\n"); } getch(); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator