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 yushuo718 at 2010-07-08 16:15:00 on Problem 1007
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int n;  // the length of the strings(0 < n <= 50)
    int m;  // the number of the strings(0 < m <= 100) 
    int i,j,k;
    char dna[110][60];
    char *aDna[60];
    int aInversion[60]={0};
    int inversion[60]={0};
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%s",dna[i]);
        for(j=0;j<n;j++)
            for(k=j+1;k<n;k++)
            {
                if(dna[i][j]>dna[i][k])
                    inversion[i]+=1;
            }
    }
    for(i=0;i<n;i++)
    {
        aDna[i] = dna[i];
    }
    for(i=0;i<n;i++)
        aInversion[i] = inversion[i];
    int temp = 0;
    char *tempC;
    for(i=0;i<n-1;i++)
        for(j=0;j<n-1;j++)
        {
            if(aInversion[j]>aInversion[j+1])
            {
                temp = aInversion[j];
                aInversion[j] = aInversion[j+1];
                aInversion[j+1] = temp;
                tempC = aDna[j];
                aDna[j] = aDna[j+1];
                aDna[j+1] = tempC;
            }
        }
    for(i=0;i<n;i++)
    {
        printf("%s",aDna[i]);    
        printf("\n");            
    }
    system("pause");
}

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