Professional Documents
Culture Documents
NIM = A11.2021.13777
CODING QUEUE
#include <iostream>
/*
nim = a11.2021.13777
*/
struct Node{
int data;
int harga;
string nama;
Node *next;
Node *prev;
};
Node *head;
Node *tail;
void awal(){
head = NULL;
tail = NULL;
};
bool isEmpty(){
if(head==NULL){
return 1;
}else{
return 0;
Node *nodeBaru;
nodeBaru->harga = hargaBaru;
nodeBaru->nama = namaBaru;
nodeBaru->next = NULL;
nodeBaru->prev = NULL;
if (isEmpty()){
// dan tail
head = nodeBaru;
tail = nodeBaru;
head->next = NULL;
head->prev = NULL;
cout << "\n barang berhasil di tambah ( nama barang = " <<head->nama << " ||harga = "<<head-
>harga<<")"<<endl;
cout <<
"====================================================================================
=============="<<endl;
}else{
cout << "\n barang berhasil di tambah ( nama barang = " <<tail->nama << " ||harga = "<<tail-
>harga<<")"<<endl;
cout <<
"====================================================================================
=============="<<endl;
if (isEmpty()){
}else
if (head->next == NULL){
head = NULL;
tail = NULL;
else {
//kalau node lebih dari 1
head -> prev = NULL; //PREV DARI HEAD KITA BUAT NULL
void tampil(){
Node *current;
if(isEmpty()){
} else{
int total = 0;
for(current=head; current!=NULL;current=current->next){
int main()
{
cout << "program queue ( antrian) kasir Bu Rum"<< endl;
tambahBlkng(2000,"marimas");
tambahBlkng(2000,"sosis");
tampil();
tambahBlkng(56000,"Beras");
tampil();
tampil();
hapusDpn();
tampil();
return 0;
HASIL
Coding stack
/* nama programer = EKA ARYA PRANATA
*/
#include <iostream>
struct Node{
int harga;
string nama;
Node *next;
Node *prev;
};
Node *head;
Node *tail;
void awal(){
head = NULL;
tail = NULL;
};
bool isEmpty(){
if(head==NULL){
return 1;
}else{
return 0;
}
}
Node *nodeBaru;
nodeBaru->harga = hargaBaru;
nodeBaru->nama = namaBaru;
nodeBaru->next = NULL;
nodeBaru->prev = NULL;
if (isEmpty()){
// dan tail
head = nodeBaru;
tail = nodeBaru;
head->next = NULL;
head->prev = NULL;
}else{
}
}
void hapusBlkng(){
if(isEmpty()){
}else{
if(head->next== NULL){
head = NULL;
tail = NULL;
}else{
tail = tail->prev;
tail->next = NULL;
int total = 0;
total = total + x;
return total;
void tampil(){
Node *bantu;
if(isEmpty()==0){
bantu = head;
string tumpukan[100];
int tumpukan2[100],hasil[100];
do{
tumpukan[x] = bantu->nama;
tumpukan2[y] = bantu->harga;
hasil[z] = total(bantu->harga);
bantu=bantu->next;
x++;
y++;
z++;
while(bantu!=NULL);
int hslsemua = 0;
for(int i=x-1;i>=0;i--){
cout <<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
hslsemua = hslsemua+hasil[i];
}else {
cout << "barang kosong "<<endl;
int main()
tambahBlkng(2000,"marimas");
tampil();
tambahBlkng(2000,"sosis");
tampil();
tambahBlkng(56000,"Beras");
tampil();
tampil();
hapusBlkng();
tampil();
return 0;
Hasil