fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. void poisk(std::vector<int> & massivchik)
  6. {
  7. int max = *std::max_element(massivchik.begin(), massivchik.end(),
  8. [](const int & a, const int & b)
  9. {
  10. return a < b;
  11. });
  12. for_each(massivchik.begin(), massivchik.end(),
  13. [&max](const int & value)
  14. {
  15. if (!(max - value > 1))
  16. std::cout << value << " ";
  17. });
  18. }
  19.  
  20. int main()
  21. {
  22. std::vector<int> proverochka = { 5, 6, 2, 4, 6, 5, 7, 4, 5, 3, 1, 1, 3};
  23. poisk(proverochka);
  24. return 0;
  25. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
6 6 7