fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main(){
  7. string s;
  8. cin >> s;
  9. vector<int> arr(s.size());
  10. int j = 0;
  11. for(auto ch : s){
  12. if (ch >= '0' && ch <= '9') {
  13. arr[j] = ch - '0';
  14. ++j;
  15. } else {
  16. cerr << "Bad input: " << ch << endl;
  17. }
  18. }
  19. for(int i = 0; i < j; ++i)
  20. cout << arr[i];
  21. }
Success #stdin #stdout 0s 5552KB
stdin
0135
stdout
0135