fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner sc=new Scanner(System.in);
  14. // int a=10,b=20;
  15. // a=a+b;
  16. // b=a-b;
  17. // a=a-b;
  18. // System.out.println(a+" "+b);
  19.  
  20. int arr[]={1,1,3,2,2,1,5};
  21. for (int i = 0; i < arr.length; i++) {
  22. int count = 0;
  23.  
  24. for (int j = i+1; j < arr.length; j++) {
  25. if (arr[i] == arr[j]) {
  26. count++;
  27. }
  28. }
  29.  
  30. System.out.println(arr[i] + " -> " + count);
  31. }
  32.  
  33. }
  34. }
Success #stdin #stdout 0.22s 58836KB
stdin
Standard input is empty
stdout
1 -> 2
1 -> 1
3 -> 0
2 -> 1
2 -> 0
1 -> 0
5 -> 0