题解 | #DNA序列#

DNA序列

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

#include <stdio.h>
#include <string.h>

int main() {
    char str[1000];
    int n;
    scanf("%s %d",str,&n);
    int len = strlen(str);
    int i,j;
    int max = 0;
    char str1[1000]={0};
    for(i=0;i<len;i++)
    {
       int a = 0;
       for(j=i;j<i+n;j++)
       {
           if(str[j] == 'C' || str[j] == 'G' && j<len)
           a++;
       }
       if(a > max) 
       {
           max = a;
           memcpy(str1,str+i,n);   //从str[i]到str[i+n-1]复制给str1
       }
    }
    printf("%s",str1);
    return 0;
}

全部评论

相关推荐

程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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