public int[] InsertInArray(int[] array) { Arithmetic a = new Arithmetic(); int average = a.arithmetic(array); Calculator calculator = new Calculator(); int[] result = calculator.NewArray(array); int k = 0; for (int i = 0; i < array.Length; i++) { if (Math.Abs(array[i]) <= average) { result[k] = array[i]; } if (Math.Abs(array[i]) > average) { result[k] = array[i]; result[k + 1] = 0; k++; } k++; } return(result); }
public int[] NewArray(int[] array) { Arithmetic a = new Arithmetic(); int average = a.arithmetic(array); int index = 0; for (int i = 0; i < array.Length; i++) { if (Math.Abs(array[i]) > average) { index++; } } int[] result = new int[array.Length + index]; return(result); }