fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. vector<string> combo1;
  11. vector<string> combo2;
  12. vector<int> combo3;
  13. istringstream foo("a1 b00 2222\na1 b01 233\na1 b92 34444\na2 b00 2222\na2 b00 3333\na2 b01 3333");
  14. vector<string> combos{istream_iterator<string>(foo), istream_iterator<string>()};
  15.  
  16. for(auto i = 0; i < combos.size(); ++i) {
  17. switch(i % 3) {
  18. case 0:
  19. combo1.push_back(combos[i]);
  20. break;
  21. case 1:
  22. combo2.push_back(combos[i]);
  23. break;
  24. case 2:
  25. combo3.push_back(stoi(combos[i]));
  26. }
  27. }
  28.  
  29. for(const auto& i : combo1) cout << i << ' ';
  30. cout << endl;
  31. for(const auto& i : combo2) cout << i << ' ';
  32. cout << endl;
  33. for(const auto& i : combo3) cout << i << ' ';
  34. cout << endl;
  35. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
a1 a1 a1 a2 a2 a2 
b00 b01 b92 b00 b00 b01 
2222 233 34444 2222 3333 3333