题解 | #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")

全部评论

相关推荐

码农索隆:单休一个月少休息4天,一年就是48天,平时节假日,别人3天假期,单休的两天
点赞 评论 收藏
分享
能干的三文鱼刷了10...:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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