Skip to content

Instantly share code, notes, and snippets.

@ProZhar
Created December 3, 2015 11:57
Show Gist options
  • Save ProZhar/9005761c3a0420b242e3 to your computer and use it in GitHub Desktop.
Save ProZhar/9005761c3a0420b242e3 to your computer and use it in GitHub Desktop.
com.javarush.test.level08.lesson11.bonus03
package com.javarush.test.level08.lesson11.bonus03;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/* Задача по алгоритмам
Задача: Введи с клавиатуры 20 слов и выведи их в алфавитном порядке.
*/
public class Solution
{
public static void main(String[] args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] array = new String[20];
for (int i = 0; i < array.length; i++)
{
array[i] = reader.readLine();
}
sort(array);
for (String x : array)
{
System.out.println(x);
}
}
public static void sort(String[] array)
{
//напишите тут ваш код
Arrays.sort(array); // :) без циклов и нижней функции
}
//Метод для сравнения строк: 'а' больше чем 'b'
public static boolean isGreaterThan(String a, String b)
{
return a.compareTo(b) > 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment