Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <windows.h>
- using namespace std;
- int pil;
- void pilih();
- void hapusdata();
- void buat_baru();
- void tambah_depan();
- void hapus_depan();
- void tampil();
- struct node
- {
- char angka[13];
- string nama;
- string alamat;
- node *prev, *next;
- };
- node *baru, *head=NULL, *tail=NULL,*hapus,*bantu,*bantu2;
- int main(){
- do{
- system("cls");
- cout<<"SELAMAT DATANG DI E-BUKTEL "<<endl;
- cout<<"=========================\n";
- cout<<"1. Tamabah Kontak"<<endl;
- cout<<"2. Hapus Kontak"<<endl;
- cout<<"3. lihat kontak"<<endl;
- cout<<"4. Keluar"<<endl;
- cout<<"Pilihan : ";cin>>pil;
- pilih();
- }
- while(pil!=4);
- }
- void pilih(){
- if(pil==1)
- tambah_depan();
- else if(pil==2)
- hapus_depan();
- else if(pil==3)
- tampil();
- else
- cout<<"selesai";
- }
- void buat_baru(){
- baru =new(node);
- cin.ignore();
- cout<<"\nMasukkan Nama\t: ";
- getline(cin,baru->nama);
- cout<<"Masukkan Alamat\t: ";
- getline(cin,baru->alamat);
- cout<<"Masukkan No HP : ";cin>>baru->angka;
- baru->prev=NULL;
- baru->next=NULL;
- }
- void tambah_depan(){
- buat_baru();
- if(head==NULL){
- head=baru;
- tail=baru;
- }
- else{
- baru->next=head;
- head->prev=baru;
- head=baru;
- }
- cout<<endl;
- tampil();
- }
- void hapus_depan() {
- if (head==NULL)
- cout<<"Kosong";
- else if(head->next==NULL){
- hapus=head;
- head=NULL;
- tail=NULL;
- delete hapus;
- }
- else {
- hapus=head;
- head=hapus->next;
- head->prev=NULL;
- delete hapus;
- }
- cout<<endl<<endl;
- tampil();
- }
- void tampil(){
- if (head==NULL)
- cout<<"Kosong\n";
- else {
- bantu=head;
- int no=0;
- while(bantu!=NULL){
- no++;
- cout<<"Kode : ";cout<<" "<<no<<" "<<endl;
- cout<<"Nama : ";cout<<bantu->nama<<endl;
- cout<<"alamat : ";cout<<bantu->alamat<<endl;
- cout<<"No.Hp : ";cout<<bantu->angka<<endl;
- cout<<"==================="<<endl;
- bantu=bantu->next;
- }
- }system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement