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 |
麻烦过掉的高手看看啦~ 实在不知道哪里有bug 万分感激````#include <iostream.h> #include <string.h> int n,m; int lenth[101]; char str[101][50]; int ord[101]; int main() {int i,j,t; memset(lenth,0,sizeof lenth); cin>>n>>m; for(i=1;i<=m;i++) cin>>str[i]; for(i=1;i<=m;i++) for(j=0;j<n;j++) for(t=j+1;t<n;t++) if (str[i][t]-'A'<str[i][j]-'A') lenth[i]++; for(i=1;i<=m;i++) ord[i]=i; for(i=m;i>=1;i--) for(j=1;j<i;j++) { if (lenth[ord[j]]>lenth[ord[j+1]]) { t=ord[j]; ord[j]=ord[j+1]; ord[j+1]=t; } } for(i=1;i<=m;i++) cout<<str[ord[i]]<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator