Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. private static void mode() {
  2. int[] count = new int[100];
  3. int[] a = {27, 15, 15, 11, 27};
  4. int max = 0;
  5. for(int i = 0;i < a.length;i++){
  6. count[a[i]]++;
  7. }
  8. for(int i = 0;i < count.length;i++){
  9. if(count[i] > max){
  10. max = count[i];
  11. }
  12. }
  13. for(int i = 0;i < count.length;i++){
  14. if(count[i] == max){
  15. System.out.println(i);
  16. break;
  17. }
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement