【字符串】HDU5590ZYB's Biology【BestCoder Round #65】
2016-04-24 12:50
351 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5590
Problem Description
After getting 600 scores
in NOIP ZYB(ZJ−267) 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;The RNA 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.
1≤T≤10,1≤N≤100
Output
For each testcase,print YES or NO,describe
whether the two arrays are matched.
Sample Input
2
4
ACGT
UGCA
4
ACGT
ACGU
Sample Output
YES
NO
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
char a[1101],b[1100],c[110];
char change(char s)
{
char ss='0';
if(s=='A') ss='U';
else if(s=='C') ss='G';
else if(s=='G') ss='C';
else if(s=='T') ss='A';
return ss;
}
int main()
{
int t,n;
scanf("%d",&t);
//getchar();
while(t--){
getchar();
scanf("%d",&n);
getchar();
for(int i=0;i<n;i++){
scanf("%c",&a[i]);
c[i]=change(a[i]);
//cout<<c[i];
}
getchar();
//cout<<endl;
int flag=0;
for(int i=0;i<n;i++){
scanf("%c",&b[i]);
if(c[i]!=b[i]) flag=1;
}
if(flag) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}
Problem Description
After getting 600 scores
in NOIP ZYB(ZJ−267) 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;The RNA 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.
1≤T≤10,1≤N≤100
Output
For each testcase,print YES or NO,describe
whether the two arrays are matched.
Sample Input
2
4
ACGT
UGCA
4
ACGT
ACGU
Sample Output
YES
NO
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
char a[1101],b[1100],c[110];
char change(char s)
{
char ss='0';
if(s=='A') ss='U';
else if(s=='C') ss='G';
else if(s=='G') ss='C';
else if(s=='T') ss='A';
return ss;
}
int main()
{
int t,n;
scanf("%d",&t);
//getchar();
while(t--){
getchar();
scanf("%d",&n);
getchar();
for(int i=0;i<n;i++){
scanf("%c",&a[i]);
c[i]=change(a[i]);
//cout<<c[i];
}
getchar();
//cout<<endl;
int flag=0;
for(int i=0;i<n;i++){
scanf("%c",&b[i]);
if(c[i]!=b[i]) flag=1;
}
if(flag) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}
相关文章推荐
- Ajax参数记录
- angular $apply()以及$digest()讲解
- FFmpeg-20160422-snapshot-bin
- 专题二 1012
- 第八周总结及H5、Js实现五子棋效果
- FudionCharts简单学习记录
- HDU 1236 排名(一大波输入)
- 图片拉伸的方法
- 计算机视觉目标检测的框架与过程
- C语言 结构体中的成员域偏移量
- leetcode-169. Majority Element
- <学习笔记> adr 与 ldr 的使用及两者的区别(基于ARM架构 )
- @property
- 查看修改mysql编码方式
- Django
- Retrofit
- 目标检测的图像特征提取之(三)Haar特征
- 不得不说的谷歌开发者模式:谷歌调试模式调试js代码总结
- jdbc基础
- 目标检测的图像特征提取之(二)LBP特征