Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int main(String[] args){
- int[] a = new int[12];
- for (int i = 0; i < a.length; i++) {
- a[i] = ((int)(Math.random() * 12));
- System.out.println(a[i]);
- } int index = 0 ;
- int soFar = 1 ;
- int count = 1 ;
- for(int k =1; k < a.length; k++){
- if (a[k-1] == a[k]){
- count++ ; }
- if(count > soFar)
- {
- soFar = count ;
- index = k ;
- }
- else {
- count = 1 ;
- }
- }
- return a[index] ;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement