Advertisement
Anuva

mapping

Feb 17th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,q,i,marks;
  6. string name;
  7. //std::map<name,marks>m;
  8. map<string,int>m;
  9. cin>>t;
  10. for(i=0;i<t;i++)
  11. {
  12. cin>>q;
  13. if(q==1)
  14. {
  15. cin>>name>>marks;
  16.  
  17. m.insert(make_pair(name,marks));
  18. }
  19.  
  20. if(q==2)
  21. {
  22. m.erase(name);
  23. }
  24. if(q==3)
  25. {
  26. cout<<m[name];
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement