Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a program that reads from the console a sequence of N integer numbers and returns the minimal and maximal of them.
- using System;
- class MinAndMaxNumber
- {
- static void Main()
- {
- Console.Write("How many numbers you want to write: ");
- int N = int.Parse(Console.ReadLine());
- int count = 1;
- int max = int.MinValue;
- int min = int.MaxValue;
- while (count <= N)
- {
- int num = int.Parse(Console.ReadLine());
- count++;
- if (max < num)
- {
- max = num;
- }
- if (min > num)
- {
- min = num;
- }
- Console.WriteLine("{0} {1}", max, min);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement