Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class RepeatingNumbers {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = Integer.parseInt(sc.nextLine());
- int arr [] = new int[n];
- int count [] = new int[10];
- for (int i = 0; i < n; i++) {
- arr [i] = Integer.parseInt(sc.nextLine());
- }
- for (int i = 1; i <= 10; i++) {
- int counter = 0;
- for (int j = 0; j < arr.length; j++) {
- if(i == arr [j]){
- counter++;
- count [i-1] = counter;
- }
- }
- }
- int maxCount = 0;
- int maxRepNumber = 0;
- for (int i = 0; i < count.length; i++) {
- if(maxCount<count[i]){
- maxCount = count[i];
- maxRepNumber = i + 1;
- }
- }
- System.out.println(maxRepNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment