Denis_Hristov

QuickSortMainMethod

Jan 20th, 2021 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class QuickSortMain {
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.  
  8.         System.out.println("Please input the number of elements: ");
  9.         int n = scan.nextInt(); // Въвеждаме брой елементи
  10.  
  11.         int [] arr = new int[n];
  12.  
  13.         for (int i = 0; i < n; i++) {
  14.             System.out.printf("Please input [%d] element: ", i);
  15.             arr[i] = scan.nextInt(); // Въвеждаме всеки елемент от масива
  16.         }
  17.  
  18.         System.out.println("Before Sorting: " + Arrays.toString(arr)); // Масива преди сортиране
  19.         QuickSortMethods.QuickSort(arr,0,arr.length - 1);
  20.         System.out.println("After Sorting: " + Arrays.toString(arr)); // Масива след сортиране
  21.     }
  22. }
  23.  
Add Comment
Please, Sign In to add comment