| ||||||||||
| 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 | |||||||||
菜鸟为所有奋斗在0点以后的同学们加油,sample对了为何WA??#include<stdio.h>
int num(char *p)
{
int count=0;
char *i=p,*j=p;
for(;*(p+2)!='\0';p++)
for(j=p+1;*j!='\0';j++)
if(*p>*j)
count++;
return count;
}
main()
{
int i,j,t,first,second,count[51][2];
char a[51][102];
long b[51][2];
while(scanf("%d %d",&first,&second)!=EOF)
{
for(i=0;i<second;i++)
scanf("%s",&a[i]);
for(i=0;i<second;i++)
{
count[i][0]=i;
count[i][1]=num(*(a+i));
}
for(i=0;i<second;i++)
{
for(j=0;j<second-1;j++)
if(count[j][1]>count[j+1][1])
{
t=count[j][1];
count[j][1]=count[j+1][1];
count[j+1][1]=t;
t=count[j][0];
count[j][0]=count[j+1][0];
count[j+1][0]=t;
}
}
for(i=0;i<second;i++)
{
printf("%s\n",a[count[i][0]]);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator