5.33 · exercise
Min-max tournament
Find the smallest and the largest element of an array in one pass, and print both. The starter reads a count and then that many values into the word array entries.
Both records start at element zero (the starter already does this); then walk the rest of the array once. Each element gets two comparisons: one against the minimum and one against the maximum.
What is checked
minandmaxeach printed on their own line- the program exits cleanly
- comparisons decide the records (
cmppresent) - the same holds for other arrays you do not see: one element, all equal, negatives, and the smallest or largest value at either end
specification
stdin8
58 3 77 12 41 90 6 25
stdoutprints the right output
exitexits with the right code
sourceuses
cmphiddenright output and exit code on 4 more inputs you do not see
We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.