Mencari Nilai Minimal dan Maksimal Update (Menggunakan 1 Looping)

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package nilaiMinMax1for;

/**
*
* @author ANGGA
*/
public class nilaiMinMax1for {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic
int min,max;
int[][]array={{1,2,3},{4,5},{6,7,8}};
min = array[0][0];
max = array[0][0];
for(int a=0;a<array.length;a++){
for(int b=0;b<array[a].length;b++){
if(array[a][b]<min){
min=array [a][b];
}
if(array[a][b]>max){
max=array[a][b];
}
}
}
System.out.println(“Nilai Min : “+min);
System.out.println(“Nilain Max : “+max);
}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s