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

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 10:39
一个证都没&nbsp;我能填什么
程序员小白条:别人有,你为什么没有,还是这个道理,社会就是比较,竞争,淘汰,你要安逸,那么就要做好淘汰的准备
点赞 评论 收藏
分享
认真搞学习:28小登的建议,投算法岗不要写什么物理竞赛,互联网+,多写点项目,用什么算法做了什么。还有本科算法是不可能的开发你这个也没有项目啊
点赞 评论 收藏
分享
07-09 15:55
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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