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 TotoAdams at 2006-12-02 15:10:30
In Reply To:帮忙看看,不知道错在哪,提交总是不对 Posted by:TotoAdams at 2006-12-02 11:59:21
> #include <stdio.h>
> #include <limits.h>
> void main()
> {
> 	int length, total, i, j, k, minIndex, temp;
> 	short int key[100] = { 0 };
> 	char str[100][50] = { '\0' };
> 
> 	scanf("%d%d", &length, &total);
> 
> 	if ( ! (length > 0 && length <= 50) && (total > 0 && total <= 100) )
> 		return ;
> 	for ( i = 0; i < total; i++)
> 		scanf("%s", str[i]);
> 
> 	for ( i = 0; i < total; i++)
> 	{
> 		for ( j = 0; j < length; j++)
> 		{
> 			for ( k = j + 1; k < length; k++)
> 				if ( str[i][j] > str[i][k] )
> 					key[i]++;
> 		}
> 	}
> 
> 	for ( i = 0; i < total; i++)
> 	{
> 		temp = INT_MAX;
> 		for ( j = 0; j < total; j++)
> 		{
> 			if ( key[j] < temp && key[j] >= 0)
> 			{
> 				minIndex = j;
> 				temp = key[j];
> 			}
> 		}
> 		printf("%s\n", str[minIndex]);
> 		key[minIndex] = -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