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 |
哪位仁兄可以帮帮小妹,总是runtimeerror我也搞不清啦,急急急!!!!!!!!#include<stdio.h> #include<string.h> void main() { char D[100][50],c[50]; int n,m,mark[100]={0},min=10000,b,t,i,p,k,j; scanf("%d %d",&n,&m); getchar(); for(i=0;i<m;i++) { gets(D[i]); D[i][n]='\0'; for(j=0;j<n-1;j++) for(k=j+1;k<n;k++) if(D[i][j]>D[i][k])mark[i]++; } for(i=0;i<m;i++) { min=10000; for(k=i+1;k<m;k++) { if(mark[k]<min){ min=mark[k]; b=k;} } if(min<mark[i]) { strcpy(c,D[i]); strcpy(D[i],D[b]); strcpy(D[b],c); t=mark[i]; mark[i]=mark[b]; mark[b]=t; } } for(p=0;p<m;p++) {puts(D[p]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator