Maximum and its position (read until EOF) EASY Fisiere (BAC) Tablouri vectori (BAC) 10 XP 0 solved
Mobile coding works. A laptop is faster for long sessions.

Problem

Read integers from standard input, separated by spaces or newlines. The number of values is **not known in advance**; reading ends when end of input (EOF) is reached. Print to standard output, separated by a space, the maximum value and its position (first occurrence, counting from `1`). If no values are read, print the word `vid`. **Data is read from standard input** (in the format described), not from a file. Use `while (cin >> x)` to detect end of input.

Input format

Input input.txt

On one or more lines: integers separated by spaces or newlines. Their count is between `0` and `10000`. - integers are in the range `[-1000000000, 1000000000]` - the number of values is between `0` and `10000`

Output format

Output output.txt

- if at least one value exists: the maximum and the position of its first occurrence, separated by a space; - if the input is empty: the word `vid`.

Example

input
3 1 4 1 5 9 2 6 5 3
output
9 6

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