61.5k views
4 votes
Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, add it to the array only if it's not a duplicate of a number already read. Provide for the "worst case" in which all 20 numbers are different. Use the smallest possible array to solve this problem.

1 Answer

5 votes

Final answer:

The question involves using a one-dimensional array in programming to handle up to 20 unique numbers between 10 and 100, adding only non-duplicate numbers to the array.

Step-by-step explanation:

To solve the problem of reading in 20 numbers between 10 and 100 and adding each number to an array only if it isn't a duplicate, a one-dimensional array is used. The array should be initialized with a size of 20 to account for the worst-case scenario, where all numbers are unique. As numbers are read, a search function checks if the number already exists in the array; if not, the number is added to the array. The solution requires efficient handling of the array and a condition to check for duplicates.

User Groozin
by
7.7k points