knikolov98

Untitled

Sep 25th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace NumSequence
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int num = int.Parse(Console.ReadLine());
  10.  
  11.             int minValue = int.MaxValue;
  12.             int maxValue = int.MinValue;
  13.  
  14.             int currentNum = 0;
  15.  
  16.             for (int i = 0; i < num; i++)
  17.             {
  18.                 currentNum = int.Parse(Console.ReadLine());
  19.  
  20.                 if (currentNum <= minValue)
  21.                 {
  22.                     minValue = currentNum;
  23.  
  24.                 }
  25.  
  26.                if (currentNum >= maxValue)
  27.                 {
  28.                     maxValue = currentNum;
  29.                 }
  30.             }
  31.  
  32.             Console.WriteLine($"Max number: {maxValue}");
  33.             Console.WriteLine($"Min number: {minValue}");
  34.         }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment