Advertisement
ChaeYuriya

main.cpp

Nov 3rd, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include "SLL.cpp"
  3.  
  4. void SearchDataProduk(List L){
  5.     string input;
  6.     cout << "Masukan nama produk yang dicari : ";
  7.     cin >> input;
  8.     address check = findInfo(L,input);
  9.     if(check != NULL){
  10.         cout << "PRODUK DITEMUKAN PADA ALAMAT "<< check << endl;
  11.     }else{
  12.         cout << "MAAF PRODUK TIDAK DITEMUKAN";
  13.     }
  14. }
  15.  
  16. int main(){
  17.     List data;
  18.     createList(data);
  19.     string input;
  20.     for(int x = 0;x<5;x++){
  21.         cout << "Masukan nama produk ke-" << x+1 << " : ";
  22.         cin >> input;
  23.         address adds = alokasi(input);
  24.         insertLast(data,adds);
  25.     }
  26.     cout << "Daftar produk saat ini adalah : ";
  27.     Show(data);
  28.     cout<<endl;
  29.     SearchDataProduk(data);
  30.     cout<<endl;
  31.     SearchDataProduk(data);
  32.     cout<<endl;
  33.  
  34.     cout << "Daftar Awal produk : ";
  35.     Show(data);
  36.     while(first(data) != NULL){
  37.         cout << "Lokasi produk yang dihapus (depan/belakang) ? ";
  38.         cin >> input;
  39.         address deleted;
  40.         if(input == "depan"){
  41.             deleteFirst(data,deleted);
  42.         }else if(input == "belakang"){
  43.             deleteLast(data,deleted);
  44.         }
  45.  
  46.         if(deleted != NULL){
  47.             cout << "Data yang dihapus : " << info(deleted) << endl;
  48.             cout << "Daftar setelah dihapus : ";
  49.             Show(data);
  50.         }
  51.         cout << endl;
  52.     }
  53.     cout << "SELESAI" << endl;
  54. }
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement