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啊!!小第先谢了。

Posted by 20054953 at 2007-01-10 10:56:40 on Problem 1007
#include"stdio.h"
void main()
{int n,m,i,j,k,sum[100],d[50],c;
 char a[100][50];
 scanf("%d %d\n",&n,&m);

 for(i=0;i<m;i++)
    {for(j=0;j<n;j++)
         scanf("%c",&a[i][j]);
         if (i!=m-1) scanf("\n");
     }
     
          
 for(i=0;i<m;i++)
     {sum[i]=0;
      for(j=0;j<n-1;j++)
          for(k=j+1;k<n;k++)
              if(a[i][j]>a[i][k])
                 sum[i]=sum[i]+1;
      }
 for(i=0;i<m;i++)
     d[i]=sum[i];
 for(i=1;i<m;i++)
     for(j=0;j<m-i;j++)
         if(d[j]>d[j+1])
           {c=d[j];
            d[j]=d[j+1];
            d[j+1]=c;
            }
 for(i=0;i<m;i++)
    {if(d[i]==d[i+1]) continue;
     for(j=0;j<m;j++)
         if(d[i]==sum[j])
            {for(k=0;k<n;k++)
                printf("%c",a[j][k]);
                printf("\n");
             }
      }
  }




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