The task: to write an algorithm that allows generating two new arrays from an array of numbers - the first one contains only negative and the second one only positive.
Question: It seems everything wrote everything works, that's just how to get rid of the empty values of the array. I know that you can add the size of an array when adding a number to this array, but I do not know how to write it.
Aogitrm:
class Program { static void Main(string[] args) { Random ran = new Random(); int[] main_mas = new int[6]; // Создаем главный массив for (int i = 0; i < main_mas.Length; i++) // Вводим переменные main_mas[i] = ran.Next(minValue: -20, maxValue: 20); int[] mas1 = new int[6]; // Создаем отриц. массив int[] mas2 = new int[6]; // Создаем плож. массив for (int i = 0; i < main_mas.Length; i++) { if (main_mas[i] < 0) mas1[i] = main_mas[i]; else mas2[i] = main_mas[i]; } Console.WriteLine("Исход: \n"); for (int i = 0; i < main_mas.Length; i++) Console.WriteLine(main_mas[i]); Console.WriteLine("Отриц: \n"); for (int i = 0; i < mas1.Length; i++) Console.WriteLine(mas1[i]); Console.WriteLine("полож: \n"); for (int i = 0; i < mas2.Length; i++) Console.WriteLine(mas2[i]); Console.ReadKey(); } } 