using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DraftForLab2 { class Program { static void DoBlock_1() { Console.WriteLine("Введіть кількість елементів n:"); int n = int.Parse(Console.ReadLine()); if (n <= 0) { Console.WriteLine("n має бути додатним."); return; } Console.WriteLine("Введіть {0} цілих чисел (кожне з нового рядка):", n); int x = int.Parse(Console.ReadLine()); int min = x; int max = x; for (int i = 2; i <= n; i++) { x = int.Parse(Console.ReadLine()); if (x < min) min = x; if (x > max) max = x; } long result = (long)min + max; Console.WriteLine("Мінімум = {0}, максимум = {1}, їх сума = {2}", min, max, result); } static void DoBlock_2() { Console.WriteLine("Вводьте цілі числа по одному. Завершіть послідовність нулем:"); int count = 0; int x = int.Parse(Console.ReadLine()); while (x != 0) { if (x % 2 != 0) count++; x = int.Parse(Console.ReadLine()); } Console.WriteLine("Кількість непарних елементів = {0}", count); } static void DoBlock_3() { int i = 0; double u; do { i++; u = Math.Cos(1.0 / Math.Tan(i)); } while (u >= 0); Console.WriteLine("Перше від'ємне число: u_{0} = {1}", i, u); } static void Main(string[] args) { int choice; do { Console.WriteLine("Для виконання блоку 1 (варіант 10) введіть 1"); Console.WriteLine("Для виконання блоку 2 (варіант 29) введіть 2"); Console.WriteLine("Для виконання блоку 3 (варіант 43) введіть 3"); Console.WriteLine("Для виходу з програми введіть 0"); choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("Виконую блок 1"); DoBlock_1(); break; case 2: Console.WriteLine("Виконую блок 2"); DoBlock_2(); break; case 3: Console.WriteLine("Виконую блок 3"); DoBlock_3(); break; case 0: Console.WriteLine("Зараз завершимо, тільки натисніть будь ласка ще раз Enter"); Console.ReadLine(); break; default: Console.WriteLine("Команда ``{0}'' не розпізнана. Зробіть, будь ласка, вибір із 1, 2, 3, 0.", choice); break; } } while (choice != 0); } } }