Sequential Search

public class SequentialSearch {
public static void main(String[] args) {
int a[] = new int[4];
int x, i, posisi;
boolean ada;

a[0]=2;
a[1]=62;
a[2]=32;
a[3]=42;

ada = false;
posisi = 0;
x = 32;

for(i=0;i<3;i++){
if(a[i]==x){
ada = true;
if(ada = true){
System.out.print(“Ketemu posisi ” +(i)+”\n”);
}
else {
System.out.print(“Tidak ada”);
}
}
}
}
}

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 )

Gambar Twitter

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

Foto Facebook

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

Foto Google+

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

Connecting to %s