#include <stdio.h>
double foo_cg( const char* atucg )
{
size_t cg=0, total=0;
for( ; *atucg; ++atucg )
{
switch( *atucg )
{
case 'C': case 'c':
case 'G': case 'g':
++cg;
case 'A': case 'a':
case 'T': case 't':
case 'U': case 'u':
++total;
}
}
return total==0? 0.0 : cg*100.0/total;
}
int main()
{
scanf("%s",foo_cg);
double result = foo_cg("");
printf( "此序列中G+C的百分含量为:%.2f%%\n", result );
return 0;
}
错误比较多啊
#include <stdio.h>
double foo_cg( const char* atucg )
{
size_t cg=0, total=0;
for( ; *atucg; ++atucg )
{
switch( *atucg )
{
case 'C':
case 'c':
case 'G':
case 'g':
++cg;
case 'A':
case 'a':
case 'T':
case 't':
case 'U':
case 'u':
++total;
}
}
return total==0? 0.0 : cg*100.0/total;
}
int main()
{
char atucg[1000] = {0};
scanf("%s",atucg);
double result = foo_cg(atucg);
printf( "此序列中G+C的百分含量为:%.2lf%\n", result );
return 0;
}
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632