void hapus_abjad(char abjad) { char tekan=0; int n; do{ textcolor(7); gotoxy(3,3); printf("1. Hapus di bagian Belakang Loco "); gotoxy(3,4); printf("2. Hapus di bagian Belakang Gerbong "); gotoxy(3,5); printf("3. Hapus di Bagian Tengah Gerbong "); gotoxy(3,2); printf("Pilih : "); clreol(); tekan=getche(); switch(tekan) { case '1' : hapus_awal(&awal,&akhir); break; case '2' : hapus_akhir(&awal,&akhir); break; case '3' : hapus_tengah(&awal,&akhir,n); break; } }while(tekan!='1'&&tekan!='2'&&tekan!='3'); } void hapus_awal(point *awal, point *akhir) { point hapus; if(*awal==NULL) { gotoxy(3,19);printf("Gerbong Tidak bisa dihapus. Data Kosong.\n"); getch(); } else if(*awal==*akhir) { free(*awal); *awal=*akhir=NULL; } else
{ hapus=*awal; *awal=(*awal)->next; free(hapus); } getch(); } void hapus_akhir(point *awal, point *akhir) { point hapus,bantu; if(*awal==NULL) { gotoxy(3,19);printf("Gerbong Tidak bisa dihapus, Data Kosong.\n"); getch(); } else if(*awal==*akhir) { free(*akhir); *akhir=*awal=NULL; } else { bantu=*awal; while(bantu->next!=*akhir) { bantu=bantu->next; } free(*akhir); bantu->next=NULL; *akhir=bantu; } getch(); } void hapus_tengah(point *awal, point *akhir, int n) { int i,hapus; point bantu,bantu2; if(*awal==NULL) { gotoxy(3,19);printf("Gerbong Dalam Linked List Kosong, Data Kosong \n"); getch(); } else {
This document was created with Win2PDF available at http://www.daneprairie.com. The unregistered version of Win2PDF is for evaluation or non-commercial use only.