BubaLazi

Smallest Element in Array

Jul 10th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 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 ArraysLab
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var stringArr = Console.ReadLine().Split(' ');
  14.             var arr = new int[stringArr.Length];
  15.  
  16.             for(int i = 0; i < arr.Length; i++)
  17.             {
  18.                 arr[i] = int.Parse(stringArr[i]);
  19.             }
  20.  
  21.             var min = int.MaxValue;
  22.             for(int i = 0; i < arr.Length; i++)
  23.             {
  24.                 if (arr[i]< min)
  25.                 {
  26.                     min = arr[i];
  27.                 }
  28.  
  29.             }
  30.             Console.WriteLine(min);
  31.  
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment