I've got the perfect the output, but the console keeps saying that my code does not pass the last condition.
Does anyone know What the problem is here?
package com.codegym.task.task07.task0728;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
/*
In decreasing order
Task: Write a program that reads 20 numbers from the keyboard
and displays them in decreasing order.
*/
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 < 20; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
sort(array);
for (int x : array) {
System.out.println(x);
}
}
public static void sort(int[] array) {
//write your code here
Arrays.sort(array);
for (int i = 0; i <= 10; i++) {
int temp = array[i];
array[i] = array[19 - i];
array[19 - i] = temp;
}
}
}