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

为什么一直都是WA???贴出代码,请大虾指点!

Posted by ccnufu at 2008-08-27 10:45:18 on Problem 1007
#include <stdio.h>
#include <string.h>

main()
{
	short n, m, i, j, k;
	char str[101][51]={0}, t[51]={0};
	long num[100]={0}, temp;

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

	for(i=1; i<m; i++)
		for(j=0; j<m-i; j++)
			if(num[j] > num[j+1])
			{
				temp = num[j];
				num[j] = num[j+1];
				num[j+1] = temp;
				 strcpy(t, str[j]);
				 strcpy(str[j], str[j+1]);
				 strcpy(str[j+1], 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