Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- void remove(std::map<int,int> &m, int index)
- {
- for (auto itr = m.cbegin(), itr2 = itr; itr != m.cend(); itr = itr2)
- {
- ++itr2;
- if (itr->first<index)
- {
- m.erase(itr);
- }
- }
- }
- int main()
- {
- std::map<int, int> map {{7,1}, {3,8}, {5,7}, {1,4}, {4,5}, {8,3}};
- remove(map,5);
- for(auto pair: map){
- std:: cout<< pair.first<<" "<<pair.second<<std::endl;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement