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

有没有那位牛人能指点一下?谢谢

Posted by quanjianan at 2005-09-09 18:32:37 on Problem 1007
#include "stdio.h"

main()
{
  long int n,m,k,i,j,sum[100];
  char a[100][50],c,temp[100][50];
  scanf("%d%d",&n,&m);
  scanf("%c",&c);
  for(i=0;i<m;i++)
    {
      for(j=0;j<n;j++)
         scanf("%c",&a[i][j]);
      scanf("%c",c);
     }
   for(i=0;i<=m-1;i++)
      for(j=0;j<=n-1;j++)
        for(k=1;k<n-j;k++)
             if ( a[i][j]>a[i][j+k])
                sum[i]++;
  for (i=0;i<=m-1;i++)
    {
       i=k;
       for (j=i+1;j<=m-1;j++)
       if (sum[k]<sum[j])
          k=j;
       if (i!=k)
         {
            for (j=0;j<=n-1;j++)
              {
                 temp[i][j]=a[i][j];
                 a[i][j]=a[k][j];
                 a[k][j]=temp[i][j];

              }
         }
    }
   for (i=0;i<m;i++)
     {
       for (j=0;j<n;j++)
         printf("%c",a[i][j]);
       printf("\n");
     }


    getch();
}

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