Source Code :
/* Sorting Teknik Insertion */
#include <stdio.h>
int a;
int data[5]={3,2,1,5,4};
void sort(){
int temp, key , i;
for(a=1;a<5;a++){
key=data[a];
i=a-1;
while (i>=0 && data[i]>key ){
data[i+1]=data[i];
i=i-1;
data[i+1]=key;
}
}
}
void view(){
for(a=0;a<5;a++){
printf(" %d ",data[a]);
}
printf("\n");
}
int main(){
clrscr();
printf(" Sorting Teknik Insertation \n");
printf("==============================\n");
printf(" Sebelum di-sorting : \n");
view();
sort();
printf(" Sesudah di-sorting : \n");
view();
getch();
}
Screen Shoot :
Nah, Sekian itu codeng nya mas mba bro, kalo masi susah ato mau coba ni program silahkan download link dibawah ini ! okey :) :D
0 komentar:
Posting Komentar