In line 37, I'm trying to find the index of the element.
I'm not sure this would be an effective way to solve the task anyway.
Any help appreciated.
package com.codegym.task.task08.task0826;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
/*
Five winners
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] array = new int[20];
for (int i = 0; i < array.length; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
sort(array);
System.out.println(array[0]);
System.out.println(array[1]);
System.out.println(array[2]);
System.out.println(array[3]);
System.out.println(array[4]);
}
public static void sort(int[] array) {
//write your code here
for(int i = 0; i<array.length-1; i++){
int a = array[i];
for(int x= i+1; x<array.length; x++){
if(a<array[x]){
int index = binarySearch(array, a);
array[index] = array[x];
array[x] = a;
i=-1;
}
}
}
}
}