how do I print the complement of a number or character

in c++ how do I print the complement of a number or character?
hello
I'm writing a bioinformatics program that performs the transcription process and I need it to print out the complement of these 4 letters (A complement U, G complement C, C complement G and T complement A) how do I get the program to automatically print out the letters complement
here's my code so far
it reads the characters from a file and then for each character I want it to print out the complement
could i use a nested switch statement
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
switch (input){
case 1:
char transcription[100];
ifstream sequence;
cin.getline(transcription, 100);
sequence.open(transcription);

if(!sequence.is_open()){
exit(EXIT_FAILURE);
}

char transcription2[100];
sequence>>transcription2;
while(sequence.good()){
cout<<transcription2<<" ";

**********************//this is where the code for the complement to the letter must come in*************

sequence>>transcription2;
}

please help thank you!!!
For example you can define a map the following way

std::map<char, char> m;

Then fill it with your pairs of characters.

So then you read a character, for example, 'A', its compliment is very easy to get with expression m['A'];
Another way is to use an array of std::pairs or two arrays or pointers to string literals. For example

const char *base = "AGCT";
const char *complement = "UCGA";

and then search read character in the frist array and get complement by index of found character in the first array.

Topic archived. No new replies allowed.