I solved the problem in Python, but when using the random.shuffle module, periodically, the console does not display the correct answer. Without using the module errors do not occur!
Given the real numbers a1, a2, ..., an. Among them are positive and negative. Replace with zeros those numbers whose magnitude is greater than the maximum number (| ai |> max {a1, a2, ..., an}).
import random c = [2, -2, -6, -8, 7, -9, 1, -3, -5, -11, 3, -7, -10, 0, -1, 4, -4, -12, 5, 6] random.shuffle(c) b = max(c) for i in c: if abs(c[i]) > b: c[i] = 0 print(c) So, can withdraw such an answer:
[0, -7, -2, 0, 0, -5, -3, 5, -6, -4, <strong>-11</strong>, 0, 3, -1, 4, 7, 1, 0, 2, 6]. Where <strong>-11</strong> should not be!