Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void print_map(map<int, string> m);
- void print_vector(vector<pair<int, string>> m);
- int main(){
- map<int,string> test_map;
- test_map.insert({1201, "Abhijit Paul"});
- test_map.insert({1299, "Robin ho"});
- test_map.insert({1203, "Shazzad Hossain"});
- for(auto itr: test_map ){
- itr.second = itr.second+" ALIVE";
- }
- print_map(test_map); // NO change
- printf("After using &:\n");
- for(auto& itr: test_map){
- test_map.erase(itr.first);
- test_map.insert({itr.first-1200, itr.second+" ALIVE"});
- }
- print_map(test_map);
- return 0;
- }
- void print_map(map<int, string> m){
- for(const auto itr: m) cout<<itr.first<<","<<itr.second<<endl;
- }
- void print_vector(vector<pair<int, string>> m){
- for(const auto itr: m) cout<<itr.first<<","<<itr.second<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement