import jeliot.io.*;
public class Modus {
public static void main(String[] args) {
int a[]={2,2,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5,5,5};
int c=a[0];
int b=0;
int hasil=0,besar=0;
for (int i=0; i<a.length ;i++){
if(a[i]==c){
System.out.print(a[i]+" ");
System.out.println(++b);
if(b>besar){
besar=b;
hasil=c;
}
}else{
c=a[i];
b=1;
System.out.print(a[i]+" ");
System.out.println(b);
}
}
System.out.println("Modus = "+hasil);
}
}
Friday, February 24, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment