Advertisement
Guest User

ExampleOnMap

a guest
Nov 12th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /*
  2. Phung, Brian
  3.  
  4. October 30, 2019
  5.  
  6. CS A250
  7. Lab 9
  8. */
  9.  
  10. #include <algorithm>
  11.  
  12. #ifndef FUNCTIONS_H
  13. #define FUNCTIONS_H
  14.  
  15. // Definition of function difference
  16. int difference(const set<int> x)
  17. {
  18. return *x.rbegin() - *x.begin();
  19. }
  20.  
  21. // Definition of function multiplesOfTen
  22. void multiplesOfTen(map<int, int> &map)
  23. {
  24. int multiple = 0; //declare a default value
  25. for (auto& pair : map)
  26. {
  27. if ((pair.first % 10) == 0)
  28. multiple = pair.first / 10;
  29. else
  30. pair.second = multiple * 10;
  31. }
  32. }
  33. // Definition of function afterFive
  34. void afterFive(const multiset<int> &filled, multiset<int> &empty)
  35. {
  36. auto pair = filled.equal_range(5); //pair of iterators
  37.  
  38. while (pair.second != filled.end())
  39. {
  40. empty.insert(*(pair.second));
  41. pair.second++;
  42. }
  43. }
  44.  
  45. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement