Advertisement
zeneksilant

3

Oct 9th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public static int main(String[] args){
  2. int[] a = new int[12];
  3. for (int i = 0; i < a.length; i++) {
  4. a[i] = ((int)(Math.random() * 12));
  5. System.out.println(a[i]);
  6. } int index = 0 ;
  7. int soFar = 1 ;
  8. int count = 1 ;
  9. for(int k =1; k < a.length; k++){
  10. if (a[k-1] == a[k]){
  11. count++ ; }
  12. if(count > soFar)
  13. {
  14. soFar = count ;
  15. index = k ;
  16. }
  17. else {
  18. count = 1 ;
  19. }
  20. }
  21. return a[index] ;
  22. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement