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 wwwwwwking at 2008-03-22 14:57:09 on Problem 1007
#include <iostream>
using namespace std;


struct nx
{
       int nx;
       char xulie[55];       
}a[105];


int Nixu(char *str,int len)
{
     int i;
     int nxx=0;
     int a[4]={0};
     for (i=len-1;i>=0;--i)
     {
         switch(str[i])
         {
               case 'A':
                         a[0]++;
                         a[1]++;
                         a[2]++;
                         break;
               case 'C':
                           a[1]++;
                           a[2]++;
                           nxx+=a[0]; 
                           break;  
                         
                          
               case 'G':
                           a[2]++;
                           nxx+=a[1];
                           break; 
               case 'T': 
                           nxx+=a[2];
                           break;     
         }    
     }    
return nxx;
}


int main ()
{
     char input[55];
      int n,t,nx,end,i,j,k,flag;
      end=0;
      cin>>n>>t;
      cin>>input;
      nx=Nixu(input,n);
      a[0].nx=nx;
      strcpy(a[0].xulie,input);
      while (--t)
      {
           flag=0;
           cin>>input;
           nx=Nixu(input,n);
           for (i=0;i<end;++i)
           {
                 if (nx>a[i].nx)
                 {   flag=1;      break; }   
           }    
           if (flag)
           {      for (j=end;j>=i;--j)
                  {
                       a[j+1].nx=a[j].nx;
                       strcpy(a[j+1].xulie,a[j].xulie);
                  }    
                  a[i].nx=nx;
                  strcpy(a[i].xulie,input);
                  end++;
           }  
           else  
           {
                  a[end+1].nx=nx;
                  strcpy( a[end+1].xulie,input );
                  end++;      
           }
      } 
      for (k=0;k<t;++k)
           printf("%s\n",a[k].xulie);
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