Advertisement
MilaDimitrovaa

QuickSort - Main

Jan 8th, 2021
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package QuickSort_183_02;
  2. import java.util.Arrays;
  3. import java.util.Scanner;
  4. import static QuickSort_183_02.QuickSort_Method.*;
  5.  
  6. public class QuickSort_Main {
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scan = new Scanner(System.in);
  10.  
  11.         int N = scan.nextInt(); //number of elements
  12.         //  int N = Integer.parseInt(scan.nextLine()); // same as above
  13.  
  14.         int [] arr = new int[N];
  15.  
  16.         //for cycle to fill up the array
  17.  
  18.         for (int i = 0; i < N; i++) {
  19.  
  20.             System.out.printf("Please,input the [%d] element : " , i);
  21.  
  22.             arr[i] = scan.nextInt();
  23.         }
  24.  
  25.         //before sorting
  26.         System.out.println("BEFORE SORTING : " + Arrays.toString(arr));
  27.  
  28.         // Call QuickSort
  29.         QuickSort(arr, 0, N - 1);
  30.  
  31.         // after sorting
  32.         System.out.println("AFTER SORTING : " + Arrays.toString(arr));
  33.     }
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement