Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. int main()
  2. {
  3. // ...
  4. auto employee_less_than = [] (const Employee& lhs, const Employee& rhs)
  5. {
  6. return lhs.get_balance() < rhs.get_balance();
  7. };
  8. std::vector<Employee> employees_sorted;
  9. // ...
  10. int total_funds /* = ... */;
  11. std::sort(employees_sorted.begin(), employees_sorted.end(), employee_less_than);
  12. for (auto& e : employees_sorted) {
  13. if (e.get_salary() <= total_funds) {
  14. total_funds -= e.get_salary();
  15. e.pay_salary();
  16. }
  17. }
  18. // ...
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement