Approximate search

Report a typo

Download the file. The first line contains a sorted array of numbers. In this array, you need to find the nearest number for each number from the second row. If two numbers are equidistant from the one you're analyzing, select the left value. As an outcome, specify these nearest values.

Sample Input 1:

11 22 33 35 41 47 51 56 67 73 76 77 84 85 91
83 94 66 78 51 22 94 73 60 26 17 48 51 1 84

Sample Output 1:

84 91 67 77 51 22 91 73 56 22 22 47 51 11 84
Write code in your IDE to process the text file and display the results below
___

Create a free account to access the full topic