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 cshhy at 2014-03-24 16:53:50 on Problem 1007
#include<stdio.h>
struct Ch
{
	int count;
	char c[50];
}ch[100],p;

int main()
{
	int n,m,i,j,k;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%s",ch[i].c);
		for(j=0;j<n;j++)
			for(k=j+1;k<n;k++)
				if(ch[i].c[j]>ch[i].c[k])
					ch[i].count++;
	}
	for(i=0;i<m;i++)
		for(j=i+1;j<m;j++)
			if(ch[i].count>ch[j].count)
			{
				p=ch[i];
				ch[i]=ch[j];
				ch[j]=p;
			}
	for(i=0;i<m;i++)
		printf("%s\n",ch[i].c);
	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