Created
December 3, 2015 10:06
-
-
Save ProZhar/60a9dc0653225c3133f3 to your computer and use it in GitHub Desktop.
com.javarush.test.level08.lesson11.home08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level08.lesson11.home08; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.Arrays; | |
import java.util.Collections; | |
/* Пять наибольших чисел | |
Создать массив на 20 чисел. Заполнить его числами с клавиатуры. Вывести пять наибольших чисел. | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
Integer[] array = new Integer[20]; //int заменили на Integer | |
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(Integer[] array) // тоже замена на объект | |
{ | |
//напишите тут ваш код | |
Arrays.sort(array, Collections.reverseOrder()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment