There was a problem, please help me solve it with "system.indexoutofrangeexception". An error occurs here:
Console.WriteLine("Массив с нечетного ряда чисел: "); for (i = 0; i < 30; i++) Console.Write(" {0}", b[i]); (ЗДЕСЬ!) Console.ReadLine(); Help please solve. It is necessary that from the initial array only those digits remain that stand in odd places (1,3,5,7,9 etc)
using System; namespace tapsyrma { class Program { static void Main(string[] args) { int i, k,y=0; int[] a = new int[30]; int[] b = new int[(a.Length + 1) / 2]; Random rnd = new Random(); Console.WriteLine("Исходный массив: "); for (i = 0; i < 30; i++) { a[i] = rnd.Next(-50, 51); Console.Write(" {0}", a[i]); } for (i = 0; i <30; i++) { if (a[i] % 2 != 0) y++; } Console.WriteLine(); for (i = 0, k = 0; i < b.Length; i++, k+=2) { b[i] = a[k]; } Console.WriteLine("Массив с нечетного ряда чисел: "); for (i = 0; i < 30; i++) Console.Write(" {0}", b[i]); Console.ReadLine(); } } }