fork(2) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. const string str("atgctgttg");
  10. const int n = 5; // Assumed positive number smaller than str.size()
  11. const int n1 = n - 1;
  12. vector<string> result(str.size() - n1);
  13.  
  14. transform(str.cbegin(), str.cend() - n1, result.begin(), [n](const auto& i) {return string(&i, n);});
  15.  
  16. for (auto& i : result) {
  17. cout << i << endl;
  18. }
  19. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
atgct
tgctg
gctgt
ctgtt
tgttg