SHARE
TWEET

Untitled

a guest Nov 20th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package dilam;
  2. import java.util.Scanner;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. public class DiLam
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.         Scanner mk= new Scanner(System.in);
  10.         int n;
  11.         n= mk.nextInt();
  12.         if (n<2|| n>1000000)
  13.         {
  14.             System.out.print("\n Erorr !!"); return;
  15.         }
  16.         int k;
  17.         int min =1000000;
  18.         int [] A= new int[n];
  19.         for(int i=0;i<n;i++)
  20.         {
  21.             A[i]= mk.nextInt();//
  22.         }
  23.         for(int i=0;i<n-1;i++)
  24.         {
  25.             for(int j=i+1;j<n;j++)
  26.             {
  27.                 k= Math.abs(A[i]-A[j]);
  28.                 if (min>k) min=k;      
  29.             }
  30.         }
  31.         System.out.format("\n%d\n",min );  
  32.     }
  33.    
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top