EmiliaKitkarska

Zadacha5

Apr 19th, 2021
673
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 5. Сортиране на числа
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.List;
  6. import java.util.Scanner;
  7.  
  8. public class Zadachki {
  9.  
  10.     public static void print(List<Integer> numbers) {
  11.         System.out.print(numbers.get(0));
  12.         for (int i = 1; i < numbers.size() - 1; i++) {
  13.             System.out.print(" <= " + numbers.get(i));
  14.         }
  15.         System.out.print(" <= " + numbers.get(numbers.size() - 1));
  16.     }
  17.  
  18.     public static void main(String[] args) {
  19.         Scanner scan = new Scanner(System.in);
  20.         String[] input = scan.nextLine().split(" ");
  21.         List<Integer> numbers = new ArrayList<>();
  22.  
  23.         for (String val : input) {
  24.             numbers.add(Integer.parseInt(val));
  25.         }
  26.  
  27.         Collections.sort(numbers);
  28.         print(numbers);
  29.  
  30.  
  31.     }
  32. }
  33.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×