Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- import java.util.stream.Collectors;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // double [] numbers=Arrays.stream(scanner.nextLine().split(" "))
- // .mapToDouble(Double::parseDouble)
- // .toArray();
- List<Double> nums = Arrays.stream(scanner.nextLine().split(" "))
- .map(Double::parseDouble)
- .collect(Collectors.toList());
- TreeMap<Double, Integer> counts = new TreeMap<>();
- for (Double num : nums) {
- if (!counts.containsKey(num)) {
- counts.put(num, 0);
- }
- counts.put(num, counts.get(num) + 1);
- }
- for (Map.Entry<Double, Integer> entry : counts.entrySet()) {
- System.out.printf("%.0f -> %d%n", entry.getKey(), entry.getValue());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement