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 |
我感觉知道题用c写很简单,但是不知道有很多人用其他语言写的那么复杂,我的,16Ms 576B#include<stdio.h> #include<string.h> int main() { int m,n,str[108]={0},i,j,s=0,k,temp; char string[108][100],ss[58]; scanf("%d %d",&n,&m); for(k=0;k<m;k++) { scanf("%s",string[k]); for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { if(string[k][i]>string[k][j]) str[k]++; } } for(j=0;j<m-1;j++) for(i=0;i<m-1-j;i++) if(str[i]>str[i+1]) { temp=str[i]; str[i]=str[i+1]; str[i+1]=temp; strcpy(ss,string[i]); strcpy(string[i],string[i+1]); strcpy(string[i+1],ss); } for(i=0;i<m;i++) printf("%s\n",string[i],str[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