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 holmes93 at 2012-01-21 11:08:59 on Problem 1007
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
  int len,n,i,j,k,count;
  char s[52][101]={0};
  char *p[100],*temp;
  
  /*输入并计算逆序*/
  scanf ("%d%d",&len,&n);
  getchar();
  for (i=0;i<n;i++)           
  {
    gets(s[i]);
    p[i]=s[i];
    count=0;
    for (j=0;j<len-1;j++)
    {
        for (k=j+1;k<len;k++)
            if (s[i][j]>s[i][k])
                count++;
    } 
    s[i][51]=count;     
  }
  
  /*逆序数排序*/ 
  for (i=1;i<n;i++)
    for (j=0;j<n-i;j++)
    {
        if (p[j][51]>p[j+1][51])
        {
            temp=p[j];
            p[j]=p[j+1];
            p[j+1]=temp;    
        }    
    }
    
  /*输出*/
  for (i=0;i<n;i++)
    puts(p[i]);

  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