Practice
Maximum, Minimum and Range
2021/May/Jun·Variant 2·Q2(a)·[6 marks]
MEDIUMLoops
Read N positive integers (each less than 1000). Find and output the largest, smallest, and range (largest minus smallest) — each on a separate line.
Source: 2021 May/Jun Variant 2 Q2(a)
Input: N on the first line (2 ≤ N ≤ 10), then N integers. Output: Three lines — largest, smallest, range.
Example:
Input: 5
34
12
78
5
56
Output: 78
5
73
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Mixed values
Inputs: 5, 34, 12, 78, 5, 56
Expected: 78
5
73
Test 2: 3 numbers
Inputs: 3, 100, 50, 75
Expected: 100
50
50
Test 3: All same — range is 0
Inputs: 4, 10, 10, 10, 10
Expected: 10
10
0
Ctrl+Enter
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade