import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner teclado = new Scanner(System.in);
    int vec[] = new int[10];
    int repetidos[] = new int[10]; 
    int cont[] = new int[10];
    int i, j, c, k=0;
    for(i=0; i<10; i++) {
        vec[i] = teclado.nextInt();
    }
    for(i=0; i<9; i++) {
        c=0;
        for (j=i+1; j<10; j++) {
            if (vec[i] != -1 && vec[i] == vec[j]) { 
                c++;
                vec[j] = -1;
            }
        }
        if (c > 0) {
            repetidos[k] = vec[i];
            cont[k] = c+1;
            k++;
        }        
    }
    for (i=0; i<k-1; i++) {
        System.out.println(repetidos[i] + " " + cont[i] + " ");
    }  
    System.out.println(repetidos[k-1] + " " + cont[k-1]);
  }
}









Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: