PRG/211 Week 4 Lab 9.2 Arrays: Middle item

$ 8

PRG/211 Week 4 Lab 9.2 Arrays: Middle item

Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd.

Ex: If the input is 2 3 4 8 11 -1 (a negative indicates end), the output is:
4
The maximum number of inputs for any test case should not exceed 9. If exceeded, output “Too many inputs”.

Hint: Use an array of size 9. First read the data into an array. Then, based on the number of items, find the middle item.

892 in stock

Description

PRG/211 Week 4 Lab 9.2 Arrays: Middle item

Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd.

Ex: If the input is 2 3 4 8 11 -1 (a negative indicates end), the output is:
4
The maximum number of inputs for any test case should not exceed 9. If exceeded, output “Too many inputs”.

Hint: Use an array of size 9. First read the data into an array. Then, based on the number of items, find the middle item.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

You may also like…