I am remember a task , I leave it when I was in tenth leven because I wanna to solve it now and repeat some tasks which I solved before , but the complier don't want to say me , ohh you solve it right way , I look on the result , I repeat it 3 times , and every time in my opinion all gonna be right;
Just look at this code and help me , perhaps I do not see what you have seen.
package com.codegym.task.task10.task1020;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] array = new int[30];
for (int i = 0; i < 30; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
sort(array);
System.out.println(array[9]);
System.out.println(array[10]);
}
public static void sort(int[] array) {
for (int i = 1 ; i < array.length ; i++){
int indexOfMin = i;
for (int j = i + 1 ; j < array.length ; j++){
if (array[indexOfMin] > array[j]){
indexOfMin = j;
}
}
int temp = array[indexOfMin];
array[indexOfMin] = array[i];
array[i] = temp;
}
}
}