Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3. Числа квадрати
- import java.util.*;
- public class Zadachki {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String [] input = scan.nextLine().split(" ");
- int arr[] = new int[input.length];
- for (int i = 0; i < input.length; i++) {
- arr[i] = Integer.parseInt(input[i]);
- }
- HashSet set = new HashSet<Integer>();
- for(int k:arr){
- double value = Math.sqrt(k);
- if (value == (int) value) {
- set.add(k);
- }
- }
- List<Integer> result = new ArrayList<>(set);
- Collections.sort(result);
- Collections.reverse(result);
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement