One day, Billy Gates wants to design a C++ code to sort his employee’s salary in decreasing order. Eaach one is paid according to working time * hourly rate. Finish the TODO part below:
Hints:
Certain functions associated with the vector are:
begin()– Returns an iterator pointing to the first element in the vector
end() – Returns an iterator pointing to the theoretical element that follows the last element in the vector
push_back()– It pushes the elements into a vector from the back
vector<int>::iterator ptr; // Declaring iterator to a vector
input example:
3 // number of employees
1 3 // id=1, the first number means "time" and the other means "hourly rate"
3 3 // id=2, the first number means "time" and the other means "hourly rate"
2 3 // id=3, the first number means "time" and the other means "hourly rate"
output example:
Before sorting
id:Salary
1:3 // 3=1*3(time*hourly_rate)
2:9 // 9=3*3(time*hourly_rate)
3:6 // 6=2*3(time*hourly_rate)
After sorting
id:Salary
2:9
3:6
1:3