anizko

04. Number sequence

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