hdoj-5590-ZYB's Biology

来源:互联网 发布:sass for mac中文版 编辑:程序博客网 时间:2024/06/05 00:11

Problem Description
After getting 600 scores in NOIPZYB(ZJ267) begins to work with biological questions.Now he give you a simple biological questions:
he gives you a DNA sequence and a RNA sequence,then he asks you whether the DNA sequence and the RNA sequence are
matched.

The DNA sequence is a string consisted of A,C,G,T;TheRNA sequence is a string consisted of A,C,G,U.

DNA sequence and RNA sequence are matched if and only if A matches U,T matches A,C matches G,G matches C on each position.
 

Input
In the first line there is the testcase T.

For each teatcase:

In the first line there is one number N.

In the next line there is a string of length N,describe the DNA sequence.

In the third line there is a string of length N,describe the RNA sequence.

1T10,1N100
 

Output
For each testcase,print YES or NO,describe whether the two arrays are matched.
 

Sample Input
24ACGTUGCA4ACGTACGU
 

Sample Output
YESNO
 

高中生物题,DNA和RNA的匹配

#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;bool judge(char x,char y){    if(x=='A'&&y=='U') return true;    else if(x=='T'&&y=='A') return true;    else if(x=='C'&&y=='G') return true;    else if(x=='G'&&y=='C') return true;    return false;}int main(){    int t;    scanf("%d",&t);    char d[100],r[100];    while(t--)    {        int n;        bool flag=true;        scanf("%d",&n);        scanf("%s",d);        scanf("%s",r);        //printf("%s %s\n",dna,rna);        for(int i=0;i<n;i++)        {            flag=judge(d[i],r[i]);            //printf("%d\n",flag);            if(flag==false) break;        }        if(flag) printf("YES\n");        else printf("NO\n");    }    return 0;}


0 0
原创粉丝点击