Max and number of occurrences via reference MEDIUM Subprograme (BAC) 25 XP 0 solved
Mobile coding works. A laptop is faster for long sessions.

Problem

Write the definition of a subprogram `maxAparitii` with four parameters: - `v` -- a one-dimensional array with at most `100` components, containing integers - `n` -- a non-zero natural number representing the number of elements used from `v` - `mx` -- a parameter passed by reference, in which the subprogram returns the maximum value among the first `n` components of the array - `cnt` -- a parameter passed by reference, in which the subprogram returns the number of occurrences of the maximum value in the first `n` components of the array Then write a main program that reads from standard input a non-zero natural number `n` and then `n` integers separated by spaces or newlines, calls the subprogram `maxAparitii` on the read array, and prints to standard output, on a single line, the maximum value and its number of occurrences, separated by a space.

Input format

Input input.txt

The first line contains the natural number `n`. The following lines (separated by spaces or newlines) contain the `n` integers. - `1 <= n <= 100` - elements are integers with at most 4 digits, possibly with sign - the subprogram `maxAparitii` must be defined explicitly, with `mx` and `cnt` passed by reference

Output format

Output output.txt

The program prints on a single line two numbers separated by a space: the maximum value in the array and its number of occurrences.

Example

input
6
3 1 4 1 5 9
output
9 1

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