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<string.h> #include<math.h> #include<stdlib.h> int main () { char a[60][200]; int b[60],c[60]; int i,j,k,m,n,t; // freopen("x.txt","r",stdin); // freopen("out.txt","w",stdout); while(scanf("%d%d",&n,&m)!=EOF) { for(i=0;i<m;i++) b[i]=0; for(i=0;i<m;i++) c[i]=i; for(i=0;i<m;i++) scanf("%s",a[i]); for(i=0;i<m;i++) { for(j=0;j<n;j++) { for(k=j+1;k<n;k++) { if(a[i][j]>a[i][k]) b[i]++; } } } // for(i=0;i<m;i++) // printf("%d\n",b[i]); for(i=0;i<m-1;i++) for(j=0;j<m-1-i;j++) { if(b[j]>b[j+1]) { t=b[j]; b[j]=b[j+1]; b[j+1]=t; t=c[j]; c[j]=c[j+1]; c[j+1]=t; } } // for(i=0;i<m;i++) // printf("%d\n",c[i]); for(i=0;i<m;i++) printf("%s\n",a[c[i]]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator