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 suying at 2009-03-22 14:46:22 on Problem 1080
#include <iostream>
using namespace std;
int max(int a,int b,int c) 
{
	int d=(a > b ? a :b) > c ? (a > b ? a :b) : c;
	return d;
}
int table(char a, char b)
{
    int dna[5][5] =
    {
        { 5,-1,-2,-1,-3},
        { -1,5,-3,-2,-4},
        { -2,-3,5,-2,-2},
        { -1,-2,-2,5,-1},
        { -3,-4,-2,-1,0}
    };
	int m,n;
	if(a=='-') m=4;
    if(b=='-') n=4;
	if(a=='A') m=0;
	if(a=='C') m=1;
	if(a=='G') m=2;
	if(a=='T') m=3;
	if(b=='A') n=0;
	if(b=='C') n=1;
	if(b=='G') n=2;
	if(b=='T') n=3;
    return dna[m][n];
}
int main()
{
	int opt[102][102];
	int i,j,num1,num2,t,ma;
	char a[102],b[102];
	cin>>t;
	while(t--)
	{
		cin>>num1;
		cin>>a;
		cin>>num2;
		cin>>b;
		opt[0][0]=0;
		for(i=1;i<=num1;i++)
			opt[0][i] = opt[0][i-1]+table('-',a[i-1]);
	    for(i=1;i<=num2;i++)
			opt[i][0] = opt[i-1][0]+table('-',b[i-1]);
		if(num1>num2) ma=num1;
		else ma=num2;
	    for(i = 1; i <= num1; i++){
                for(j = 1; j <=num2; j++){
                        opt[i][j] = opt[i-1][j-1] + table(a[i-1],b[j-1]);
                        if(opt[i][j] < opt[i-1][j] + table(a[i-1],'-')){
                                opt[i][j] = opt[i-1][j] + table('-',a[i-1]);
                        }

                        if(opt[i][j] < opt[i][j-1] + table('-',b[i-1])){
                                opt[i][j] =opt[i][j-1] +table('-',b[i-1]);
                        }
                }
        }



        cout<<opt[num1][num2]<<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