A - Double Helix

Time Limit: 2 sec / Memory Limit: 1024 MB

Score :
100
points

Problem Statement
On the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.

You are given a letter
b
as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base
b
.

Constraints
b
is one of the letters A, C, G and T.
Input
Input is given from Standard Input in the following format:

b

Output
Print the letter representing the base that bonds with the base
b
.

Sample Input 1
Copy
A
Sample Output 1
Copy
T
Sample Input 2
Copy
G
Sample Output 2
Copy
C

题意:碱基互补配对原则,配对A-T,C-G

代码

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
using namespace std;

int main() {
	char str;
	while (cin >> str) {
		if (str == 'A') {
			cout << "T" << endl;
		}
		else if (str == 'T') {
			cout << "A" << endl;
		}
		else if (str == 'C') {
			cout << "G" << endl;
		}
		else {
			cout << "C" << endl;
		}
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_44231195/article/details/89224711