Contoh Coding Searching and Sorting

#include
#include

int main(){
int No_Peserta[10];
int j;
int cari;
int flag=0;
int temp;
int k;

printf(“\t\t\t\”NO PESERTA WIDYATAMA IDOL\”\n\n”);
printf(“Masukkan No Peserta :\n”);
for(j=1;j<=10;j++){
printf("No Peserta[%d] = ",j);scanf("%d",&No_Peserta[j]);
}

printf("\nMasukkan No Peserta yang akan di cari : ");scanf("%d",&cari);
j=0;
while((j<=10) &&(No_Peserta[j]!=cari)){
j=j+1;
}
if(No_Peserta[j]==cari){
printf("No Peserta ditemukan di elemen ke-%d \n",j);
}
else{
printf("No Peserta tidak ditemukan\n");
}

for(j=1;j=(j+1);k–){
if(No_Peserta[k] < No_Peserta[k-1]){
temp=No_Peserta[k];
No_Peserta[k]=No_Peserta[k-1];
No_Peserta[k-1]=temp;
}
}
}

printf("\nSetelah pengurutan :\n");
printf("\nTampilan No Peserta berurutan : ");
for(j=1;j<=10;j++){
printf("\nNo Peserta[%d] = %d\n", j, No_Peserta[j]);}

system("pause");

}

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