static void Main(string[] args) { double[] ex = new double[4] { 2, -6, 4, 9 }; TArray a = new TArray(4, ex); a.LowestGreatestValues(); a.Sorting(); Console.WriteLine(a.arraySum()); a.Output(); (a + 3).Output(); (a - 2).Output(); (a * 5).Output(); double[] asd = new double[4] { 4, 5, 6, 7 }; TOderedArray aa = new TOderedArray(4, asd); double[] bb = new double[3] { 4, 6, 9 }; (aa - bb).Output(); }
public static TOderedArray operator +(TOderedArray arr, double[] nums) { int newLen = arr.elemsQuantity + nums.Length; TOderedArray newArr = new TOderedArray(newLen); for (int i = 0; i < arr.elemsQuantity; i++) { newArr.array[i] = arr.array[i]; } for (int i = arr.elemsQuantity; i < newLen; i++) { newArr.array[i] = nums[i - arr.elemsQuantity]; } return(newArr); }
public static TOderedArray operator -(TOderedArray arr, double[] nums) { bool Contains(double[] array, double value) { if (array == null) { return(false); } for (int j = 0; j < array.Length; j++) { if (array[j] == value) { return(true); } } return(false); } int newLen = arr.elemsQuantity; for (int i = 0; i < arr.elemsQuantity; i++) { for (int j = 0; j < nums.Length; j++) { if (arr.array[i] == nums[j]) { newLen--; } } } TOderedArray result = new TOderedArray(newLen); int index = 0; for (int i = 0; i < arr.elemsQuantity; i++) { if (!Contains(nums, arr.array[i])) { result.array[index] = arr.array[i]; index++; } } return(result); }