DNA序列
2015-08-25 20:54
239 查看
找出字符串中G和C,字符个数最多的长度固定的子串
注释:求子串用M.substr(i,j) 从i开始长度为j的子串
点击打开链接
注释:求子串用M.substr(i,j) 从i开始长度为j的子串
点击打开链接
#include<iostream> #include<string> using namespace std; int main(){ string dna,temp; int count = 0,max = 0,n; cin >> dna>>n; if (n > dna.size()) return 0; else{ for (int i = 0; i <= dna.size() - n; i++){ for (int j = 0; j < n; j++){ //计算以i为起点长度为n的子串中,C和G的字符个数。 if (dna.substr(i, n)[j] == 'C' || dna.substr(i, n)[j] == 'G') count++; } if (count>max){ max = count; temp = dna.substr(i, n); } count = 0; } } cout << temp << endl; system("pause"); return 0; }
相关文章推荐
- F - 蜘蛛牌(深度搜索)
- Linux内核工程导论——内存管理(三)
- 《C Primer Plus(第五版)中文版》第13章第1至13题
- HDU 2222 — Keywords Search
- 二叉树遍历的应用(路径和问题,判断是否是二叉搜索树,判断是否是二叉平衡树)
- 使用串口AT命令驱动点阵屏 VFD
- 在jdk为1.6或1.7下,eclipse仍然报Remove '@override' annotation错误
- Android-基本控件(Toast 全解)
- Python 爬虫入门《上》
- Jenkins_Maven_Git 持续集成及自动化部署 GentOS版
- 移动WEB开发入门学习笔记
- VMware Workstation(虚拟机)v10.0.1 简体中文破解版
- 几何编程题
- 自增运算
- printf支持的格式
- 数组中出现次数超过一半的数字(算法)
- 大龄屌丝自学笔记--Java零基础到菜鸟--011
- PHP扩展模块安装
- URI(URL) 允许的字符
- HDOJ 1005 Number Sequence(规律)