fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<int> vc;
  9.  
  10. string str;
  11. getline(cin,str);
  12.  
  13. std::regex regexp(R"~(\d+)~");
  14. smatch m;
  15.  
  16.  
  17. const std::sregex_iterator itEnd;
  18. for (std::sregex_iterator it(str.begin(), str.end(), regexp); it != itEnd; ++it)
  19. {
  20. for(auto elem : *it)
  21. vc.push_back(stoi(elem));
  22.  
  23. }
  24.  
  25. for(auto i = vc.begin(); i != vc.end(); i++)
  26. cout<<*i<<endl;
  27. return 0;
  28.  
  29.  
  30. }
Success #stdin #stdout 0s 16168KB
stdin
21 2 3
stdout
21
2
3