标签:iostream span string out 完整 cout turn || bsp
一:解题思路
二:完整代码示例 (C++版和Java版)
C++代码:
#include <iostream> #include <string> using namespace std; int main() { string s = ""; int n = 0; while (cin >> s >> n) { string maxString = ""; int maxCount = 0; if (n == s.size()) maxString = s; for (int i = 0; i < s.size() - n; i++) { int j = i; int len = j + n; float count = 0; for (;j < len;j++) { if (s[j] == ‘C‘ || s[j] == ‘G‘) { count++; } } if (count > maxCount) { maxCount = count; maxString = s.substr(i, n); } } cout << maxString << endl; } return 0; }
标签:iostream span string out 完整 cout turn || bsp
原文地址:https://www.cnblogs.com/repinkply/p/13425536.html