Computer Science

# Arrays - Basic

Write a program that computes the change in the average (arithmetic mean) of an unsorted array, when each number larger than $$X$$ in the array is changed to a different number $$Y.$$

What is the biggest average among the given arrays when all the numbers larger than $$20$$ are changed to $$20$$ in the arrays below?

  1 2 3 4 5 6 7 8 9 10 [12, 10, 8, 36, 12, 10, 0, 20, 0, 2] [28, 29, 11, 29, 2, 6, 4, 7, 13, 32] [21, 32, 32, 12, 31, 20, 16, 6, 7, 11] [32, 36, 17, 5, 10, 30, 20, 7, 33, 11] [28, 10, 21, 8, 15, 15, 38, 30, 13, 4] [16, 25, 15, 35, 4, 14, 22, 22, 39, 17] [18, 5, 11, 6, 34, 8, 21, 3, 19, 22] [1, 15, 38, 33, 17, 1, 3, 25, 22, 0] [31, 1, 6, 2, 2, 14, 37, 27, 14, 14] [2, 16, 2, 18, 16, 28, 25, 30, 8, 23] 

What is the sum of the third highest number and the fifth highest number in the following unsorted array?

 1 [20, 24, 22, 13, 34, 13, 14, 33, 41, 10, 35, 1, 2, 24, 16, 20, 16, 23, 46, 41, 31, 7, 49, 25, 34, 15, 17, 18, 1, 30, 1, 17, 23, 43, 10, 4, 48, 44, 24, 23, 30, 0, 34, 30, 33, 27, 20, 42, 25, 5] 

Write a program that takes an unsorted array as an input and returns the sum of all numbers whose remainders are $$x$$, when divided by $$N$$.

What is the sum of all numbers in the array that have a remainder of $$4$$ when divided by $$6$$?

 1 [1, 28, 12, 31, 11, 5, 4, 30, 30, 8, 9, 39, 2, 5, 33, 33, 37, 5, 12, 27, 23, 39, 1, 36, 28, 33, 24, 5, 27, 36] 

×