#include <iostream>
#include <conio.h>
#include <stdio.h>
#DILARANG COPY HAK CIPTA
using namespace std;
#DILARANG COPY HAK CIPTA
int pil;
void pilih();
void buat_baru();
void inputdata();
void hapusdata();
void tampil();
#DILARANG COPY HAK CIPTAstruct node{
char nama[20];
int nim;
char kelas[30];
int ruangan;
node *prev, *next;
};
node *baru, *head=NULL, *tail=NULL,*hapus,*bantu,*bantu2;
#DILARANG COPY HAK CIPTA
int main(){
do{
system("cls");
cout<<"PEMINJAMAN RUANGAN "<<endl;
cout<<"UNIVERSITAS AHMAD DAHLAN "<<endl;
cout<<"=========================\n";
cout<<"1. Input Data"<<endl;
cout<<"2. Hapus Data"<<endl;
cout<<"3. Tampilkan"<<endl;
cout<<"4. Keluar"<<endl;
cout<<"Pilihan : ";cin>>pil;
pilih();
}
while(pil!=4);
}
#DILARANG COPY HAK CIPTA
void pilih(){
if(pil==1)
inputdata();
else if(pil==2)
hapusdata();
else if(pil==3)
tampil();
else
cout<<"selesai";
}
void buat_baru(){
baru =new(node);
cout<<"Nama \t: ";cin>>baru->nama;
cout<<"Nim \t: ";cin>>baru->nim;
cout<<"Kelas \t: ";cin>>baru->kelas;
cout<<"Ruangan : ";cin>>baru->ruangan;
baru->prev=NULL;
baru->next=NULL;
}
#DILARANG COPY HAK CIPTA
void inputdata(){
buat_baru();
if(head==NULL){
head=baru;
tail=baru;
}else{
baru->next=head;
head->prev=baru;
head=baru;
}
cout<<endl<<endl;
tampil();
}
#DILARANG COPY HAK CIPTAvoid hapusdata() {
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();
}
#DILARANG COPY HAK CIPTAvoid tampil(){
if (head==NULL)
cout<<"Kosong\n";
else {
bantu=head;
int no=0;
while(bantu!=NULL){
no++;
cout<<"=========================\n"<<endl;
cout<<"Peminjaman Ruangan"<<endl;
cout<<"\t"<<no<<" "<<endl;
cout<<"Nama : "<<bantu->nama<<" "<<endl;
cout<<"NIM : "<<bantu->nim<<" "<<endl;
cout<<"Kelas : "<<bantu->kelas<<" "<<endl;
cout<<"Ruangan : "<<bantu->ruangan<<" "<<endl;
bantu=bantu->next;
}
}system("pause");
}
#include <conio.h>
#include <stdio.h>
#DILARANG COPY HAK CIPTA
using namespace std;
#DILARANG COPY HAK CIPTA
int pil;
void pilih();
void buat_baru();
void inputdata();
void hapusdata();
void tampil();
#DILARANG COPY HAK CIPTAstruct node{
char nama[20];
int nim;
char kelas[30];
int ruangan;
node *prev, *next;
};
node *baru, *head=NULL, *tail=NULL,*hapus,*bantu,*bantu2;
#DILARANG COPY HAK CIPTA
int main(){
do{
system("cls");
cout<<"PEMINJAMAN RUANGAN "<<endl;
cout<<"UNIVERSITAS AHMAD DAHLAN "<<endl;
cout<<"=========================\n";
cout<<"1. Input Data"<<endl;
cout<<"2. Hapus Data"<<endl;
cout<<"3. Tampilkan"<<endl;
cout<<"4. Keluar"<<endl;
cout<<"Pilihan : ";cin>>pil;
pilih();
}
while(pil!=4);
}
#DILARANG COPY HAK CIPTA
void pilih(){
if(pil==1)
inputdata();
else if(pil==2)
hapusdata();
else if(pil==3)
tampil();
else
cout<<"selesai";
}
void buat_baru(){
baru =new(node);
cout<<"Nama \t: ";cin>>baru->nama;
cout<<"Nim \t: ";cin>>baru->nim;
cout<<"Kelas \t: ";cin>>baru->kelas;
cout<<"Ruangan : ";cin>>baru->ruangan;
baru->prev=NULL;
baru->next=NULL;
}
#DILARANG COPY HAK CIPTA
void inputdata(){
buat_baru();
if(head==NULL){
head=baru;
tail=baru;
}else{
baru->next=head;
head->prev=baru;
head=baru;
}
cout<<endl<<endl;
tampil();
}
#DILARANG COPY HAK CIPTAvoid hapusdata() {
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();
}
#DILARANG COPY HAK CIPTAvoid tampil(){
if (head==NULL)
cout<<"Kosong\n";
else {
bantu=head;
int no=0;
while(bantu!=NULL){
no++;
cout<<"=========================\n"<<endl;
cout<<"Peminjaman Ruangan"<<endl;
cout<<"\t"<<no<<" "<<endl;
cout<<"Nama : "<<bantu->nama<<" "<<endl;
cout<<"NIM : "<<bantu->nim<<" "<<endl;
cout<<"Kelas : "<<bantu->kelas<<" "<<endl;
cout<<"Ruangan : "<<bantu->ruangan<<" "<<endl;
bantu=bantu->next;
}
}system("pause");
}
#DILARANG COPY HAK CIPTA