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 lj__1030 at 2010-07-14 11:45:29 on Problem 1007
In Reply To:Re:我用结构体,然后排序,怎么不行呢 Posted by:cyforever at 2010-04-14 20:12:54
#include<stdio.h>
struct st{
	char str[101];
	int count;
} tt[101];
#include<stdlib.h>
int cmp(const void *a,const void *b){
	struct st *c=(struct st *)a;
	struct st *d=(struct st *)b;
	return c->count-d->count;
}
int main()
{
	int n,m,i,j,k;
	scanf("%d%d",&n,&m);
		for(i=0;i<m;i++){
				scanf("%s",tt[i].str);
				tt[i].count=0;
		}

			for(i=0;i<m;i++){
				for(j=1;j<n;j++)
					for(k=0;k<j;k++)
					if(tt[i].str[j]<tt[i].str[k])
						tt[i].count++;
				}
			qsort(tt,m,sizeof(tt[0]),cmp);
			for(i=0;i<m;i++)
				printf("%s\n",tt[i].str);

	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