题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
int n;
getline(cin, str);
//cin.get();
cin >> n;
int len=0;
double ratio;
ratio = len/n;
int temp = 0;
string word = "";
string word_temp = "";
if(n<str.size()){
for(int i=0; i<str.size()-n; i++){
temp = 0;
word_temp = "";
for(int j=0; j<n; j++){
if(str[i+j] == 'G') temp += 1;
else if(str[i+j] == 'C') temp += 1;
word_temp += str[i+j];
}
if(temp>len){
len = temp;
word = word_temp;
}
}
}
else word = str;
cout << word;
return 0;
}
// 64 位输出请用 printf("%lld")
广发银行公司氛围 23人发布