题解 | #DNA序列#

DNA序列

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

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

int main() {
    char str[1001] = { 0 };
    int n = 0;
    scanf("%s%d", str, &n);
    int len = strlen(str);
    char std[len+1][n+1];
    memset(std, 0, sizeof(std));
    int max = 0;
    int p = 0;
    for (int i = 0; i <= len- n; i++)
    {
        int c = 0;
        int map[127] = { 0 };
        for (int j = i; j < i+n; j++)
        {
            map[str[j]]++;
            std[i][c++] = str[j];
        }
        int count = map['G'] + map['C'];
        if (max < count)
        {
            max = count;
            p = i;
        }
    }
    printf("%s\n", std[p]);
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 12:20
点赞 评论 收藏
分享
陆续:不可思议 竟然没那就话 那就我来吧 :你是我在牛客见到的最美的女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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