private static void CheckRandomWriteArrayOrHand(int razm, DoubleMas[] mas, Random random, char choice) { if (choice == 'y') { for (int i = 0; i < razm; i++) { mas[i] = new DoubleMas(random.Next(0, 50) + Math.Round(random.NextDouble(), 1)); } } else { for (int i = 0; i < razm; i++) { mas[i] = new DoubleMas(double.Parse(Console.ReadLine())); } } }
static void FirstTask() { int razm; Console.WriteLine("Введите размерность"); razm = int.Parse(Console.ReadLine()); DoubleMas[] mas = new DoubleMas[razm]; Random random = new Random(); char choice; Console.WriteLine(); Console.WriteLine("Хотите забить элементы рандомом? y/n"); choice = char.Parse(Console.ReadLine()); CheckRandomWriteArrayOrHand(razm, mas, random, choice); Array.Sort(mas, mas[0].Compare); PrintArrayDouble(mas, razm); }