fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. int main(int argc, const char* argv[])
  6. {
  7. std::vector<int> someVector{5, 0, 9, 0, 6, 0};
  8.  
  9. someVector.erase(std::remove_if(someVector.begin(),
  10. someVector.end(),
  11. [](int n){ return n == 0; }),
  12. someVector.end());
  13.  
  14.  
  15. for (const auto& entry : someVector)
  16. {
  17. std::cout << entry << std::endl;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
5
9
6