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 windbells at 2004-05-08 12:55:29 on Problem 1007
#include<stdio.h>
int main()
{
	int m,n,i,j,k,sum[100];
	char arry[100][50];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%s",arry[i]);
	for(i=0;i<m;i++)
	{
		sum[i]=0;
		for(j=0;j<n-1;j++)
			for(k=j+1;k<n;k++)
				if(arry[i][j]>arry[i][k])
					sum[i]++;
	}
	for(i=0;i<m;i++)
	{
		int temp=10000;
		int tempsig=0;
		for(j=0;j<m;j++)
			if(sum[j]<temp)
			{
				temp=sum[j];
				tempsig=j;
			}
		sum[tempsig]=10001;
		printf("%s\n",arry[tempsig]);
	}
}

这样输出字符串wrong answer
如果输出改为
for(i=0;i<m;i++)
	{
		int temp=10000;
		int tempsig=0;
		for(j=0;j<m;j++)
			if(sum[j]<temp)
			{
				temp=sum[j];
				tempsig=j;
			}
		sum[tempsig]=10001;
		for(j=0;j<n;j++)
			printf("%c",arry[tempsig][j]);
		printf("\n");
	}
就对了

why???

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