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