题解 | #DNA序列#

DNA序列

https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a

#include <stdio.h>

#include <string.h>

int main() {

    int i,j,n,begin=0;//由于未对begin进行赋值,在n==strlen(str)时,发生了段错误,即溢出

    double count,max=0;

    char str[1001];

    scanf("%s",str);

    scanf("%d",&n);

    for (i=0;i<strlen(str)-n;i++)

    {

        int flag;

        count=0;

        for(flag=i;flag<n+i;flag++)

        {

            if((str[flag]=='C')||(str[flag]=='G'))

            {

                count++;

            }

        }

        if(max<count)

        {

            begin=i;

            max=count;

        }

        

    }

    for(j=begin;j<begin+n;j++)

        {

            printf("%c",str[j]);

        }

    return 0;

}

全部评论

相关推荐

Lorn的意义:你这标个前端是想找全栈吗?而且项目确实没什么含金量,技术栈太少了,边沉淀边找吧 现在学院本想就业好一点四年至少得高三模式两年加油吧
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 15:58
投个小米提前批试试水,先投一个岗位看看形势,不行就再沉淀一下投第二个岗位,莫辜负
Java抽象带篮子:我嘞个骚刚,已经开始研发6g了吗
投递小米集团等公司7个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务