每题多学点——Complementary DNA 【C语言】

一、题目

题目链接Training on Complementary DNA | Codewarsicon-default.png?t=N7T8https://www.codewars.com/kata/554e4a2f232cdd87d9000038/train/c

Instructions

Deoxyribonucleic acid (DNA) is a chemical 
found in the nucleus of cells and carries 
the "instructions" for the development 
and functioning of living organisms.

If you want to know more: 
    http://en.wikipedia.org/wiki/DNA

In DNA strings, symbols "A" and "T" are
 complements of each other, as "C" and "G". 
Your function receives one side of the DNA 
(string, except for Haskell); 
you need to return the other complementary side. 
DNA strand is never empty or there is no DNA at all 
(again, except for Haskell).

More similar exercise are found here: 
    http://rosalind.info/problems/list-view/ (source)

Example: (input --> output)

"ATTGC" --> "TAACG"
"GTAT" --> "CATA"

Sample Tests


#include <criterion/criterion.h>

char *dna_strand(const char *dna);

Test(Sample_Test, should_return_the_DNA_complementary)

{

    cr_assert_str_eq(dna_strand("ATTGC"), "TAACG");

    cr_assert_str_eq(dna_strand("GTAT"), "CATA");

}

Solution

/* Note:

    Allocate memory yourself!

*/

#include <stdlib.h>

char *dna_strand(const char *dna)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱读书的小胖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值