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 A0317462 at 2004-01-05 16:12:22 on Problem 1007
#include <stdio.h>
#include "string.h"
char map[101][51];
int sign[101];
int value[101];
int n, m;
void main()
{
	int i, j, k;
	int temp;
	int tempsig;
	int tempsigvalue;
	int l;
		scanf("%d %d", &n, &m);
		printf("\n");
		for(i = 0 ; i < m; i++)
		{
			sign[i] = i;
							
			scanf("%c", map[i]);
					
		}
		for(i=0;i<m;i++)
		{
			value[i] = 0;
			for(j = 0 ; j < n - 1; j++)
			{
				for(k = j + 1; k < n; k++)
				{
					if(map[i][j] > map[i][k])
						value[i]++;
				}
			}			
		}
		for(i=0;i<n-1;i++)
		{	
			tempsig=i;
			tempsigvalue=sign[i];
			temp=value[i];
			for(j=i;j<n;j++)
			{
				if(value[j]>temp)
				{
					temp=value[j];
					tempsig=j;
					tempsigvalue=sign[j];
				}
				
			}
			sign[tempsig]=sign[i];
			value[tempsig]=value[i];
			sign[i]=tempsigvalue;
			value[i]=temp;
		
		}

		for(i = m-1 ; i >=0 ; i--)
		{
			printf("%s\n", map[sign[i]]);
		}

}

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