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

那位老大帮帮忙!为什么总是runtime error?

Posted by cuijinbird at 2005-06-09 22:40:10 on Problem 1007
#include <stdio.h>

main()
{
    int n,m;
    int i,j,k,sortnum[50][2];
    char seq[50][101];
    scanf("%d %d",&m,&n);
    for(i=0;i<n;i++)
    {
       int count[4]={0,0,0,0};
       sortnum[i][0]=0;
       scanf("%s",seq[i]);
       seq[i][m]=0;
       for(j=m-1;j>=0;j--)
            switch (seq[i][j])
            {
                case 'A':
                    (count[0])++;
                    break;
                case 'C':
                    sortnum[i][0]+=count[0];
                    (count[1])++;
                    break;
                case 'G':
                    sortnum[i][0]+=count[0]+count[1];
                    (count[2])++;
                    break;
                case 'T':
                    sortnum[i][0]+=count[0]+count[1]+count[2];
                    break;
            }
       sortnum[i][1]=i;
    }
    for(i=0;i<n-1;i++)
    {
        k=0;
        for(j=0;j<n-i-1;j++)
           if(sortnum[j][0]>sortnum[j+1][0])
           {
              int t;
              t=sortnum[j][0];
              sortnum[j][0]=sortnum[j+1][0];
              sortnum[j+1][0]=t;
              t=sortnum[j][1];
              sortnum[j][1]=sortnum[j+1][1];
              sortnum[j+1][1]=t;
              k=1;
           }
        if(k==0)break;
    }
    for(i=0;i<n;i++)
        printf("%s\n",seq[sortnum[i][1]]);
}

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