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 |
哪位大牛帮我看看为什么会ole啊????#include<stdio.h> int measure(char string[],int m) { int measure=0; int i; int j; for(i=0;i<m-1;i++) { for(j=i+1;j<m;j++) if(string[i]>string[j]) measure++; } return measure; } int main() { char string[100][50]; char *s[100]; char *p; int i,j; int n,m; scanf("%d%d",&m,&n); for(i=0;i<n;i++) { scanf("%s",string[i]); s[i]=string[i]; } for(i=0;i<n-1;i++) { for(j=0;j<n-1-i;j++) { if(measure(s[j],m)>measure(s[j+1],m)) { p=s[j]; s[j]=s[j+1]; s[j+1]=p; } } } for(i=0;i<n;i++) printf("%s\n",s[i]); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator