Advertisement
xathrya

Double Linked List Problem

May 1st, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. void hapusTengah()
  2. {
  3.     int cari,depan;
  4.     hapus = head;   // letakan hapus pada head
  5.     cout<<"NIM yang akan dihapus : ";
  6.     cin>>cari;
  7.     if(isEmpty()==0)
  8.     {
  9.         while (hapus->next != NULL && hapus->NIM != cari)
  10.             hapus = hapus->next;
  11.        
  12.         if (hapus->NIM == cari)
  13.         {
  14.             bantu2 = hapus->next;
  15.             bantu  = hapus->prev;
  16.        
  17.             if (head != hapus)
  18.                 bantu->next = bantu2;
  19.             else
  20.                 head = bantu2;
  21.            
  22.             if (tail != hapus)
  23.                 bantu2->prev = bantu;
  24.             else
  25.                 tail = bantu;
  26.                
  27.             delete hapus;
  28.         }
  29.     }
  30.     else
  31.     {
  32.         cout<<"Tabel masih kosong"<<endl;
  33.         int nomor=0;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement