Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位仁兄可以帮帮小妹,总是runtimeerror我也搞不清啦,急急急!!!!!!!!

Posted by wo_top at 2007-11-21 18:48:48 on Problem 1007
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator