Advertisement
Atanasov_88

Min and Max sum of sequence integer numbers

Jul 6th, 2015
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class Program
  4. {
  5.  
  6.     static void Main()
  7.     {
  8.         int n = int.Parse(Console.ReadLine());
  9.  
  10.         int[] array = new int [n];
  11.  
  12.      
  13.         for (int i = 0; i < array.Length; i++)
  14.            
  15.             {
  16.              Console.WriteLine("Add element {0}", i);
  17.            
  18.            
  19.              array[i] = int.Parse(Console.ReadLine());
  20.  
  21.             }
  22.        
  23.         int min = array[0];
  24.         int max = array[0];
  25.  
  26.         for (int i = 0; i < n; i++)
  27.         {
  28.             if (min > array[i])
  29.             {
  30.                 min = array[i];
  31.             }
  32.             if (max < array[i])
  33.             {
  34.                 max = array[i];
  35.             }
  36.         }
  37.  
  38.         Console.WriteLine("The lowest integer is {0}, and the highest one is {1}", min, max);
  39.        
  40.  
  41.     }
  42.      
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement