EmiliaKitkarska

Zadacha3

Apr 19th, 2021
546
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 3. Числа квадрати
  2.  
  3. import java.util.*;
  4.  
  5. public class Zadachki {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         String [] input = scan.nextLine().split(" ");
  10.         int arr[] = new int[input.length];
  11.         for (int i = 0; i < input.length; i++) {
  12.             arr[i] = Integer.parseInt(input[i]);
  13.         }
  14.         HashSet set = new HashSet<Integer>();
  15.  
  16.         for(int k:arr){
  17.             double value = Math.sqrt(k);
  18.             if (value == (int) value) {
  19.                 set.add(k);
  20.             }
  21.         }
  22.         List<Integer> result = new ArrayList<>(set);
  23.         Collections.sort(result);
  24.         Collections.reverse(result);
  25.         System.out.println(result);
  26.     }
  27. }
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.

×