Mobile coding works. A laptop is faster for long sessions.

Problem

Consider the data type Angajat, defined as follows:

struct Angajat {
    char nume[40];
    int salariu;
};

where nume is the employee name (a single word) and salariu is the monthly salary in lei.

Read from standard input a natural number n, followed by the data for n employees. Print the employees sorted in descending order by salary. If two employees have the same salary, the one whose name is lexicographically smaller (compare with strcmp) is printed first.

Input format

Input input.txt

The first line contains `n`. The next `n` lines each contain a name and a salary, separated by a space. - `1 <= n <= 300` - salaries are natural numbers between `1` and `100000` - the name has at most 30 characters and contains no spaces - use of `strcmp` and `strcpy` (from `<cstring>`) is permitted

Output format

Output output.txt

Print `n` lines, each containing the name and salary of one employee, separated by a space, in the required order.

Example

input
4
Maria 3500
Ion 5000
Ana 2800
Vlad 5000
output
Ion 5000
Vlad 5000
Maria 3500
Ana 2800

Ready to solve this challenge?

Create a free account to write code, submit solutions, and track your progress.

⌨️ Keyboard Shortcuts

Code Editor
Run Code
Ctrl Enter
Submit Code
Ctrl Shift Enter
Format Code
Shift Alt F
Toggle Comment
Ctrl /
Undo
Ctrl Z
Redo
Ctrl Y
Navigation
Global Search
/
Show Shortcuts
?
Close Modal
Esc

🔍 Interactive Debugger

0 / 0

Analyzing your code...

📦 Variables

No variables yet

📚 Call Stack
main() line 1
📤 Output