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

DNA Sorting

Posted by liusha at 2006-09-24 13:46:46

#include "iostream.h"
#include "stdlib.h"
#include "stdio.h"
# define maxa   50
# define maxb  100
int  function(int *p,int a)
{
int k=0;
int i,j;
for(i=0;i<a-1;i++)
   for(j=i+1;j<a;j++)
	  if(p[j]<p[i])
		  k++;
	 return k;
}
int main(int argc, char* argv[])
{
 int a,b,i,j,x;
 cin>>a>>b;
 //cout<<a<<"----"<<b<<endl;
 char ch[maxa][maxb];
 int Array[maxa][maxb];

 for(i=0;i<b;i++)          
	 for(j=0;j<a;j++)
	 {
		 cin>>ch[i][j];
	     if(ch[i][j]=='A')Array[i][j]=1;
		 else
			 if(ch[i][j]=='C')Array[i][j]=2;
			 else
				 if(ch[i][j]=='G')Array[i][j]= 3;
				 else
					 if(ch[i][j]=='T')Array[i][j]= 4;
	 }
	 cout<<"----------------"<<endl;
int mark[maxb];
for(i=0;i<b;i++)
   mark[i]=function(Array[i],a);
//	cout<<"mark["<<i<<"]="<<mark[i]<<endl;
int targ1=0, s=mark[0];
for(j=1;j<a;j++)
      if(mark[j]>s)
	  {
	  targ1=j;
	  s=mark[targ1];
	  }
int MAX=mark[targ1];
//cout<<"MAX="<<MAX<<endl;
for(i=0;i<b;i++)
{ 
	int targ=0,s=mark[0];
     for(j=1;j<b;j++)
      if(mark[j]<s)
	  {
	  targ=j;
	  s=mark[targ];
	  }
	 for(x=0;x<a;x++)
        cout<<ch[targ][x];
    cout<<endl;
    mark[targ]=MAX+1;
}





 
 /*for( i=0;i<b;i++)
 {
	 for( j=0;j<a;j++)
      cout<<ch[i][j];
	 cout<<endl;
 }
  for( i=0;i<b;i++)
 {
	 for( j=0;j<a;j++)
      cout<<Array[i][j];
	 cout<<endl;
 }*/
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