SHARE
TWEET

17325 Nikola

a guest Nov 20th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class App2 {
  2.     public static void SelectSort(int[] arr){  
  3.         for (int i = 0; i < arr.length - 1; i++)
  4.         {
  5.             int index = i;
  6.             for (int j = i + 1; j < arr.length; j++) {
  7.                 if (arr[j] < arr[index]) {
  8.                     index = j;
  9.                 }
  10.             }
  11.             int currMIN = arr[index];
  12.             arr[index] = arr[i];   
  13.         }
  14.     }
  15.     public static void main(String a[]){
  16.         int[] arr1 = {7,14,66,8,53};
  17.        
  18.         System.out.println("Before sorting: ");
  19.         for(int i:arr1){
  20.             System.out.print(i+ " ");
  21.         }
  22.         System.out.println();
  23.        
  24.         SelectSort(arr1);
  25.        
  26.         System.out.println("After sorting: ");
  27.         for(int i:arr1) {
  28.             System.out.print(i + " ");
  29.        
  30.         }
  31.     }
  32.  
  33. }
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