Advertisement
Dianov

For Loop - Lab (08. Number sequence)

Dec 26th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace NumberSequence
  8.  
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             int smallest = int.MaxValue;
  16.             int biggest = int.MinValue;
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 int num = int.Parse(Console.ReadLine());
  20.                 if (num < smallest)
  21.                     smallest = num;
  22.                 if (num > biggest)
  23.                     biggest = num;
  24.             }
  25.             Console.WriteLine($"Max number: {biggest}");
  26.             Console.WriteLine($"Min number: {smallest}");
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement