进行互换就可以了
#include<stdio.h>
#include<stdlib.h>
main()
{
char input[50]/*Defined to store the DNA code sequence*/
int i/*Used as counter*/
printf("\n\tInput the DNA sequence you want to convert\n\t")
gets(input)
for(i=0input[i]!='\0'i++)
{
switch(input[i])
{
case 'A':printf("T")break
case 'T':printf("A")break
case 'C':printf("G")break
case 'G':printf("C")break
default:
{
printf("An Unknown match occurs,Fail to respond")
exit(0)/*Quit the program directly*/
}
}
}
system("pause")/*As this program is made in Dev,use this expression to pause the program*/
}
没用C写,用python写的,道理都一样。
def generate(n): //n为长度for i in range(4**n):
a=[0 for i in range(n)] //a为长度为n的一个序列
num = i
z = 0
while(num!=0):
a[z]=num%4
z = z+1
num = int(num/4)
for j in a:
if j==0:
print('A',end="")
elif j==1:
print('T',end="")
elif j==2:
print('G',end="")
else:
print('C',end="")
print()
原理就是四进制转换。
当调用函数generate(2),产生结果AA,TA,GA,CA,AT,TT,GT,CT,AG,TG,GG,CG,AC,TC,GC,CC
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)