using System; namespace ConsoleApplication1 { class Program { static double parse(string message) { Console.Write(message); string buf = ""; double y = 1,x = 1; Boolean check; ; do { try { check = true; buf = Console.ReadLine(); x = double.Parse(buf); int ix = (int)x; if ((ix / x != 1 || ix == 0 || x < 0) && message != "") throw new FormatException(); } catch { Console.ForegroundColor = ConsoleColor.Red; Console.Beep(300, 600); Console.WriteLine("Введённые данные неверны, повторите попытку" ); Console.ForegroundColor = ConsoleColor.Gray; Console.Write(message); check = false; y++; if (y > 5) { for (int t = 3; t > 0; --t) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Программа закроется через {0} с. ", t); System.Threading.Thread.Sleep(1000); } Console.Clear(); Console.ForegroundColor = ConsoleColor.Gray; Environment.Exit(0); } } Console.ForegroundColor = ConsoleColor.Gray; } while (!check && y <= 5); return x; } // метод для ввода переменных вещественного типа static void Main(string[] args) { double n1 = parse ("Введите количество элементов массива \nN = "); int n = (int)n1; double[] a = new double[n]; for (int i = 0;i0) { firstplus = a[i]; firstplusi = i; } } double lastplus = inf; for (int i = n - 1; i >= 0 && lastplus == inf; --i) { if (a[i] > 0) { lastplusi = i; lastplus = a[i]; } } bool check = true; if (firstplus == inf) { Console.WriteLine("В массиве нет положительных элементов"); check = false; } else { if (firstplusi == lastplusi) { Console.WriteLine("В массиве только один положительный элемент"); check = false; } } if (firstplusi + 1 == lastplusi) { Console.WriteLine("Последний положительный элемент идет сразу за первым"); check = false; } if (check == true) { double summ = 0; int isumm; for (isumm = firstplusi +1; isumm < lastplusi; ++isumm) { summ += a[isumm]; } Console.WriteLine("Сумма эл. массива между первым и последним положительным элементом равна " + summ); } int isort, isort2 = 0; for (isort = 0; isort < n; ++isort) { if (a[isort] == 0) { a[isort] = a[isort2]; a[isort2] = 0; isort2++; } } Console.WriteLine("Отсортированный массив:"); foreach (double element in a) { Console.Write(element + " "); } Console.WriteLine(); } } }