Advertisement
khuyenvt

Đi làm

Nov 19th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace di_lam_19_11_2019
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int n,min,a;
  11.             List<int> cong_ty =  new List<int>();
  12.             n = Convert.ToInt32(Console.ReadLine());
  13.             for(int i =0; i<n; i++ )
  14.             {
  15.                 a = Convert.ToInt32(Console.ReadLine());
  16.                 cong_ty.Add(a);
  17.             }
  18.             cong_ty.Sort();
  19.             min = cong_ty[1] - cong_ty[0];
  20.             for(int i = n-1 ; i>1; i--)
  21.             {
  22.                 a = cong_ty[i] - cong_ty[i-1];
  23.                 if (a <= min) min = a;
  24.             }
  25.             Console.WriteLine("--------------->{0}",min);
  26.             Console.ReadKey();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement