| ||||||||||
| 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 | |||||||||
看看有什么不同的地方,我的过了,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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator