Problem
In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'.
The reverse complement of a DNA string s is the string sc formed by reversing the symbols of s, then taking the complement of each symbol (e.g., the reverse complement of "GTCA" is "TGAC").
Given: A DNA string s of length at most 1000 bp.
Return: The reverse complement sc of s.
Sample Dataset
AAAACCCGGT
Sample Output
In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'.
The reverse complement of a DNA string s is the string sc formed by reversing the symbols of s, then taking the complement of each symbol (e.g., the reverse complement of "GTCA" is "TGAC").
Given: A DNA string s of length at most 1000 bp.
Return: The reverse complement sc of s.
Sample Dataset
AAAACCCGGT
Sample Output
ACCGGGTTTT
#include <stdio.h>
void main ()
{
char s[9999];
int i=0;
int cnt =0;
int cnt_a=0;
int cnt_c=0;
int cnt_g=0;
int cnt_t=0;
puts("输入:\n");
gets(s);
for(i=0;s[i]!='\0';i++)
{
if (s[i] == 'C')
{
s[i] = 'G';
continue;
}
if (s[i] == 'G')
{
s[i] = 'C';
continue;
}
if (s[i] == 'T')
{
s[i] = 'A';
continue;
}
if (s[i] == 'A')
{
s[i] = 'T';
continue;
}
}
cnt = i;
for(;cnt>0;cnt--)
{
printf("%c",s[cnt-1]);
}
}