Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- template <typename TipElemenata>
- void Odstrani(std::vector<TipElemenata> &v, TipElemenata mini, TipElemenata maxi)
- {
- for(unsigned int i(0); i < v.size(); i++)
- {
- if(v[i] < mini || v[i] > maxi)
- {
- v.erase(v.begin()+i);
- i--;
- }
- }
- }
- int main()
- {
- std::vector<int> v {3, 8, 5, 6, 1, 4, 9, 7, 2, 2, 6, 4, 9, 1, 4, 8, 3, 6, 5};
- int mini(3), maxi(7);
- Odstrani(v, mini, maxi);
- for(const auto &x : v)
- std::cout << x << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement