Advertisement
striking

Untitled

Nov 16th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. // Write a program that reads from the console a sequence of N integer numbers and returns the minimal and maximal of them.
  2.  
  3.  
  4. using System;
  5. class MinAndMaxNumber
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("How many numbers you want to write: ");
  10.         int N = int.Parse(Console.ReadLine());
  11.         int count = 1;
  12.         int max = int.MinValue;
  13.         int min = int.MaxValue;
  14.  
  15.         while (count <= N)
  16.         {
  17.             int num = int.Parse(Console.ReadLine());
  18.             count++;
  19.             if (max < num)
  20.             {
  21.                 max = num;
  22.             }
  23.  
  24.             if (min > num)
  25.             {
  26.                 min = num;
  27.             }
  28.             Console.WriteLine("{0} {1}", max, min);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement