Last active
August 28, 2018 01:20
-
-
Save rr-codes/72613d9678a6feeb3fbb116e88c70029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
float sum = 0; | |
int i = 0; | |
Map<Integer, Integer> map = new HashMap<>(); | |
for (int num = 0; num >= 0;) { | |
num = sc.nextInt(); | |
Integer value = map.get(num); | |
map.put(num, (value == null) ? 1 : value + 1); | |
int freq = map.get(num); | |
if (freq > 1) { | |
sum += num * freq; | |
i += freq; | |
} | |
} | |
if (i == 0) System.out.println("Unqe"); | |
else System.out.printf("%.2f", sum/i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment