题解 | #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; }