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

菜鸟为所有奋斗在0点以后的同学们加油,sample对了为何WA??

Posted by 12619 at 2009-06-06 02:19:32 on Problem 1007
#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:
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