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

哪位大虾帮我找找原因?????????

Posted by chenson at 2005-08-14 23:11:19 on Problem 1007
#include <stdio.h>
#include <string.h>

char str[101][51]; //修改成char str[101][101]; 就通过,51就WA,是怎么回是啊???
char t[51];//同上
int s[101];

int main()
{
    int m,n,i,j,k,c,min;

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

	for(i=1;i<m;i++)
	{
		for(j=i-1;j>=0;j--)
		{
			if(s[i]<s[j]) continue;

			else break;
		}
		min=j+1;
		if(j!=i-1)
		{
		strcpy(t,str[i]);c=s[i];
		for(j=i-1;j>=min;j--)	{strcpy(str[j+1],str[j]);s[j+1]=s[j];}
		strcpy(str[min],t);s[min]=c;}
	}
	for(i=0;i<m;i++)
		printf("%s\n",str[i]);

	return 1;
}

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