fork(1) download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. bool isNumber( const std::string& s )
  7. {
  8. for( auto c : s )
  9. {
  10. if( !std::isdigit(c) ) return false;
  11. }
  12. return true;
  13. }
  14.  
  15. int main() {
  16.  
  17. std::istream_iterator<std::string> iit(std::cin);
  18. std::vector<std::string> v;
  19. std::copy_if( iit, std::istream_iterator<std::string>(), back_inserter(v), isNumber );
  20. std::ostream_iterator<std::string> oit( std::cout, "\n");
  21. std::copy( v.begin(), v.end(), oit );
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 2992KB
stdin
I have a 3 sons
and 1 son and 25dogs
end 
stdout
3
1