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

帮我看看为什么RUNTIME ERROR!!

Posted by 13lazyrainy at 2007-05-27 10:15:04 on Problem 1007
#include <stdio.h>
#include <string.h>
int main()
{
  char str[51][101];
  char temp[51];
  int sum[51];
  int k,m,i,j,n,t;

  scanf("%d%d",&n,&m);
  for (i=0;i<m;i++) sum[i]=0;
  for (k=0;k<m;k++)
  {
	  scanf("%s",&str[k]);
	  for (i=0;i<n;i++)
		  for (j=i;j<n;j++)
		      if (str[k][i]>str[k][j])  sum[k]++;
  }

  for (i=0;i<m;i++)
	  for (j=i+1;j<m;j++)
		  if (sum[i]>sum[j]) 
		  {
			  strcpy(temp,str[i]);
			  strcpy(str[i],str[j]);
			  strcpy(str[j],temp);
			  t=sum[i];
			  sum[i]=sum[j];
			  sum[j]=t;
		  }
  for (i=0;i<m;i++)
	  printf("%s\n",str[i]);

  return 0;
}

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