fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string s = "2123dog";
  7. int n = stoi(s.substr(0, 1), NULL);
  8. int n2 = stoi(s.substr(1, n), NULL);
  9. int n3 = stoi(s.substr(1 + n, 2 + n), NULL);
  10. string resto = s.substr(2 + n);
  11. cout << n << " - " << n2 << " - " << n3 << " - " << resto;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout
2 - 12 - 3 - dog