| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
帮忙看看,不知道错在哪,提交总是不对#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator