Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Лаба2задание2
- {
- class Program
- {
- private static void Main(string[] args)
- {
- int max = Int32.MinValue; // текущее максимальное число
- int min = Int32.MaxValue; // текущее минимальное число
- bool ok = true;
- do
- {
- if (!ok)
- {
- Console.WriteLine("Ошибка! Введите другое число");
- max = Int32.MinValue;
- min = Int32.MaxValue;
- }
- Console.WriteLine("Введите число:");
- int a;
- ok = Int32.TryParse(Console.ReadLine(), out a);
- if (ok)
- {
- if (a != 0)
- {
- if (max < a)
- max = a;
- if (min > a)
- min = a;
- }
- else
- break;
- }
- }
- while (true);
- Console.WriteLine(" Сумма максимального значения {0} и минимального значения {1}: {2}", max, min, max + min);
- Console.WriteLine("Нажмите клавишу enter для завершения работы");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement