Best student by average EASY Structuri (BAC) 10 XP 0 solved
Mobile coding works. A laptop is faster for long sessions.

Problem

Consider the data type `Elev` defined as follows: ``` struct Elev { char nume[40]; int n1, n2, n3; }; ``` where `nume` is the student's name (a single word, no spaces), and `n1`, `n2`, `n3` are the student's three grades. Read from standard input a natural number `n`, followed by the data for `n` students (name and three grades). Print the name of the student with the highest arithmetic average, followed by a space and the average formatted to exactly two decimal places. If several students share the same maximum average, print the one who appears first in the input.

Input format

Input input.txt

The first line contains `n`. The next `n` lines each contain a student's name and three grades, separated by spaces. - `1 <= n <= 200` - grades are integers between `1` and `10` - the name has at most 30 characters and contains no spaces

Output format

Output output.txt

Print a single line: the name of the student with the highest average, a space, then the average with two decimal places.

Example

input
3

Ionescu 8 9 10

Popescu 7 7 7

Avram 10 10 9
output
Avram 9.67

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
We use cookies

Essential cookies are always active. You can choose to enable preference and analytics cookies. Learn more