Advertisement
MilaDimitrovaa

Main - MergeSort

Dec 18th, 2020
994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package MergeSort183_02;
  2. import java.util.Arrays;
  3. import java.util.Scanner;
  4. import static MergeSort183_02.MergeSort_Methods.Divide;
  5.  
  6. public class MergeSort_Main {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         System.out.println("Input number of elements : ");
  10.  
  11.         int N = scan.nextInt();
  12.         int [] ARR = new int[N];
  13.  
  14.         for (int i = 0; i < N ; i++) {
  15.  
  16.             System.out.println("Input element [" + i + "] : ");
  17.             ARR[i] =scan.nextInt();
  18.  
  19.         }
  20.         System.out.println("BEFORE SORTING : " + Arrays.toString(ARR));
  21.  
  22.         Divide(ARR,0,N-1);
  23.  
  24.         System.out.println("AFTER SORTING : " + Arrays.toString(ARR));
  25.  
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement