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

怎么一直是WA?找不到原因 求助呀!!!!!!!!!!!谢谢了!!!!!!!!!1

Posted by 121388552 at 2005-10-05 19:55:38 on Problem 1007
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int a,b,t;
int i,j,k,l;
scanf("%d%d",&a,&b);

char s[b][a],p[b][2],ch;


for(i=0;i<b;i++)
  scanf("%s",s[i]);

for(k=0;k<b;k++)
   p[k][0]=0;

for(i=0;i<b;i++)
 {  l=0;
 p[i][1]=i;
     for(j=0;j<a-1;j++)   
    for(k=j+1;k<a;k++) 
       if(s[i][j]>s[i][k]) l++;
       p[i][0]=l;
   }     
      

for(i=1;i<b;i++)
  for(k=0;k<b-1;k++)
    if(p[k][0]>p[k+1][0])
      {t=p[k][0];p[k][0]=p[k+1][0];p[k+1][0]=t;
       t=p[k][1];p[k][1]=p[k+1][1];p[k+1][1]=t;}  
      


 for(i=0;i<b;i++)
  {t=p[i][1];
      for(j=0;j<a;j++)  
   printf("%c",s[t][j]);
   printf("\n");
} 

  system("PAUSE");	
  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