Escolar Documentos
Profissional Documentos
Cultura Documentos
D
alam istilah ilmu komputer, sebuah struktur data adalah cara
penyimpanan, pengorganisasian dan pengaturan data di
dalam media penyimpanan komputer sehingga data tersebut
dapat digunakan secara efisien. Dalam tehnik pemrograman,
struktur data berarti tata letak data yang berisi kolom-kolom data, baik
itu kolom yang tampak oleh pengguna (user) ataupun kolom yang
hanya digunakan untuk keperluan pemrograman yang tiadak tampak
oleh pengguna. Setiap baris dari kumpulan kolom-kolom tersebut
dinamakan catatan (record).
Srtuktur Data
Struktur data adalah cara menyimpan atau merepresentasikan data di
dalam komputer agar bisa dipakai secara efisien. Sedangkan data
adalah representasi dari fakta dunia nyata. Fakta atau keterangan
tentang kenyataan yang disimpan, direkam atau direpresentasikan
dalam bentuk tulisan, suara, gambar, sinyal atau simbol.
Stack
Dalam ilmu komputer, stack atau tumpukan merupakan sebuah koleksi
objek yang menggunakan prinsip LIFO (Last In First Out), yaitu data
yang terakhr kali dimasukkan akan pertama kali keluar dari stack
tersebut. Stack dapat diimplementasikan sebagai representasi berkait
atau kontigu (dengan tabel fix).
Ciri Stack :
* Elemen TOP (puncak) diketahui
* penisipan dan penghapusan elemen selalu dilakukan di TOP
* LIFO
Pemanfaatan Stack :
* Perhitungan ekspresi aritmatika (posfix)
* algoritma backtraking (runut balik)
* algoritma rekursif
Operasi Stack yang biasanya :
1. Push (input E : typeelmt, input/output data : stack):
menambahkan sebuah elemen ke stack
2. Pop (input/output data : stack, output E : typeelmt ) :
menghapus sebuah elemen stack
3. IsEmpty ()
4. IsFull ()
5. dan beberapas selektor yang lain
#include <conio.h>
struct list{
int bil;
struct list * next;
};
typedef struct list NODE;
typedef NODE * PNODE;
PNODE masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE atas=NULL;
PNODE baru;
int pil=1;
clrscr();
while(pil!=4){
cout<<"\n\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=masuk();
PUSH(&atas, baru);
}
if (pil==2)
tampil(atas);
if (pil==3){
POP(&atas);
}
}
}
=========================== SOAL 2
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
class brg{
struct list{
char kode[10];
char nama[30];
char satu[20];
long harga;
struct list * next;
};
public:
cout <<pos->satu<<"\t";
cout <<pos->harga<<"\n";
pos=pos->next;
}
}
PNODE brg::masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nKode : ";gets(baru->kode);
cout<<"\nNama : ";gets(baru->nama);
cout<<"\nSatuan : ";gets(baru->satu);
cout<<"\nharga : ";cin>>baru->kode;
baru->next=NULL;
return(baru);
}
void main(){
PNODE atas=NULL;
PNODE baru;
int pil=1;
clrscr();
while(pil!=4){
cout<<"\n\n1. INPUT BARANG";
cout<<"\n2. LIHAT DAFTAR";
cout<<"\n3. HAPUS DAFTAR";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=x.masuk();
x.PUSH(&atas, baru);
}
if (pil==2)
x.tampil(atas);
if (pil==3){
x.POP(&atas);
}
}
}
=========================== SOAL 3
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
class elemen{
struct list{
int bil;
struct list * next;
};
public:
typedef struct list NODE;
typedef NODE * PNODE;
PNODE elemen::masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE atas=NULL;
PNODE baru;
int pil=1;
elemen data;
clrscr();
while(pil!=4){
cout<<"\n\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=data.masuk();
data.PUSH(&atas, baru);
}
if (pil==2)
data.tampil(atas);
if (pil==3){
data.POP(&atas);
}
}
}
=========================== SOAL 4
=======================
#include <iostream.h>
#include <string.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
class elemen
{
struct list
{
int bil;
struct list *next;
};
public:
typedef struct list NODE;
typedef NODE *PNODE;
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
if(*atas == NULL)
{
cout<<"\n\nSTACK KOSONG !!!\n\n";
}
else
{
if (PH -> next == NULL)
{
*atas = NULL;
free(PH);
}
else
{
*atas = (*atas) -> next;
free(PH);
}
}
getch();
}
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
{
if(*tail == NULL)
{
*head = baru;
*tail = baru;
}
else
{
(*tail) -> next = baru;
*tail = baru;
}
}
void main()
{
PNODE atas = NULL;
PNODE baru;
PNODE head = NULL,tail = NULL;
int pil=1, x, m;
char *a = "Created bY Tendi Setiadi (6306211) ";
char *b = "Í";
elemen data;
textbackground (RED);
clrscr();
m=strlen(a);
gotoxy (20,20);
for (x=0; x<m; x++)
{
cout<<*(a+x);
delay(200);
}
gotoxy (3,24);
for (x=0; x<75; x++)
{
cout<<*b;
delay(40);
}
while (pil != 3)
{
clrscr();
cout<<"\n-> Menu Utama <-"<<endl;
cout<<"\n1> Stack";
cout<<"\n2> Queue";
cout<<"\n3> Exit";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu STACK <<"<<endl;
cout<<"\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru = data.masuk_stack();
data.PUSH(&atas, baru);
}
if (pil == 2)
data.tampil_stack(atas);
if (pil == 3)
{
data.POP(&atas);
}
}
}
if (pil == 2)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu QUEUE <<"<<endl;
cout<<"\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru=data.masuk_queue();
data.INSERT_QUEUE(&tail,&head,baru);
}
if (pil == 2)
data.tampil_queue(head);
if (pil == 3)
{
data.DELETE_QUEUE(&head,&tail);
}
}
}
}
}
=========================== SOAL 5
=======================
#include "iostream.h"
#include "stdlib.h"
#include "stdio.h"
#include "conio.h"
struct list
{
char nama[35];
char kode[10];
struct list * next;
};
typedef struct list node;
typedef node * pnode;
typedef struct list NODE;
typedef NODE * PNODE;
while(POS!=NULL)
{
cout<<POS->kode<<" - ";
POS=POS->next;
}
}
PNODE MASUK(void)
{
PNODE BARU;
BARU=new(NODE);
cout<<"KODE : "; gets(BARU->kode);
BARU->next=NULL;
return(BARU);
}
while(pos!=NULL)
{
cout<<pos->nama<<" - ";
pos=pos->next;
}
}
if(*atas==NULL)
{
cout<<"\n\nSTACK KOSONG !!!\n\n";
}
else
{
if (ph->next==NULL)
{
*atas = NULL;
free(ph);
}
else
{
*atas = (*atas)->next;
free(ph);
}
}
}
pnode masuk(void)
{
pnode baru;
baru=new(node);
cout<<"\nNEGARA : "; gets(baru->nama);
baru->next=NULL;
return(baru);
}
void main()
{
pnode atas=NULL;
pnode baru;
PNODE BARU;
PNODE ATAS=NULL;
int pil=1;
clrscr();
while(pil!=4)
{
cout<<"\n\n=======STACK=======";
cout<<"\n1. PUSH STACK";
cout<<"\n2. VIEW DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. EXIT";
cout<<"\nPilihan [1/2/3/4] : "; cin>>pil;
if (pil==1)
{
clrscr();
baru=masuk();
BARU=MASUK();
push(&atas,baru);
PUSH(&ATAS,BARU);
}
if (pil==2)
{
clrscr();
tampil(atas);
TAMPIL(ATAS);
}
if (pil==3)
{
clrscr();
pop(&atas);
POP(&ATAS);
}
}
}
=========================== SOAL 6
=======================
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct simpul{
char kode[7];
char nama[20];
simpul *next;
};
class negara{
simpul *head;
public:
negara();
~negara();
void push();
void pop();
void view();
void menu();
};
negara::negara(){
head=NULL;
menu();
}
negara::~negara(){
simpul *tampung;
//tampung=head;
while(head!=NULL){
tampung=head;
head=head->next;
delete(tampung);
}
delete head;
}
void negara::menu(){
clrscr();
cout<<"\nMenu:";
cout<<"\n1. Push";
cout<<"\n2. Pop";
cout<<"\n3. View";
cout<<"\n4. Exit";
cout<<"\nPilihan[1/2/3/4]:";
int pil;
cin>>pil;
switch(pil){
case 1:push();menu();break;
case 2:pop();menu();break;
case 3:view();menu();break;
case 4:break;
default:break;
}
}
void negara::push(){
simpul *baru;
baru = new simpul;
cout<<"\nMasukkan kode negara: ";
gets(baru->kode);
cout<<"\nMasukkan nama negara: ";
gets(baru->nama);
if(head==NULL){
head=baru;
head->next=NULL;
}
else{
baru->next=head;
head=baru;
}
}
void negara::pop(){
}
void negara::view(){
simpul *lihat;
lihat=head;
while(lihat!=NULL){
cout<<"\nKode Negara:"<<lihat->kode;
cout<<"\nNama Negara:"<<lihat->nama;
lihat=lihat->next;
}
getch();
}
void main(){
clrscr();
negara stack;
getch();
}
=========================== SOAL 7
=======================
#include <stdio.h>
#include <malloc.h>
#include <string.h>
//----------------------
struct nilaiMatKul{
char nim[10];
char nama[50];
float nilai;
};
struct elemen{
nilaiMatKul elmt;
struct elemen *next;
};
struct stack{
struct elemen *top;
};
//----------------------
//----------------------
//----------------------
int hasil = 0;
if(S.top != NULL){
/* stack tidak kosong */
elemen *elmt;
/* inisialisasi */
elmt = S.top;
while(elmt != NULL){
/* proses */
hasil= hasil + 1;
/* iterasi */
elmt = elmt->next;
}
}
return hasil;
//----------------------
//----------------------
//----------------------
while(elmt != NULL){
printf("====================\n");
printf("elemen ke : %d\n", i);
printf("nim : %s\n", elmt->elmt.nim);
printf("nama : %s\n", elmt->elmt.nama);
printf("nilai : %f\n", elmt->elmt.nilai);
/* iterasi */
elmt = elmt->next;
i = i + 1;
}
printf("---------------------\n");
}
else{
/* proses jika stack kosong */
printf("stack kosong\n");
}
}
//----------------------
int main(){
struct stack S;
createEmpty(&S);
printStack(S);
printf("=================\n");
pop(&S);
pop(&S);
printStack(S);
printf("=================\n");
return 0;
}
=========================== SOAL 8
=======================
#include <stdio.h>
#include <string.h>
//----------------------
struct nilaiMatKul{
char nim[10];
char nama[50];
float nilai;
};
struct stack{
int top;
nilaiMatKul data[10];
};
//----------------------
//----------------------
if(S.top == -1){
hasil = true;
}
return hasil;
}
//----------------------
//----------------------
//----------------------
}
}
}
//----------------------
//----------------------
int main(){
struct stack S;
createEmpty(&S);
printStack(S);
printf("=================\n");
push("13507701", "Nana", 64.75, &S);
push("13507702", "Rudi", 75.11, &S);
push("13507703", "Dea", 84.63, &S);
printStack(S);
printf("=================\n");
pop(&S);
pop(&S);
printStack(S);
printf("=================\n");
return 0;
}
=========================== SOAL 9
=======================
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#define MAX_CITY 30
#define MAX_STATE 30
#define MAX_ZIP 5
void main (void);
int is_empty (struct node *);
int push (struct node **);
int pop (struct node **);
void search (struct node **);
void free_nodes (struct node **pstack);
struct node {
char zip_code[MAX_ZIP+1];
char city[MAX_CITY];
char state[MAX_STATE];
struct node *link;
};
while (test != 0)
test = pop (pstack);
}
}
}
void main()
{
struct node *top = NULL;
int n,value;
do
{
do
{
printf("Enter the element to be pushed\n");
scanf("%d",&value);
top = push(top,value);
printf("Enter 1 to continue\n");
scanf("%d",&n);
} while(n == 1);
void main()
{
clrscr();
int pilihan,baru,i;
//inisialisasi awal
tumpuk.atas=-1;
do
{
clrscr();
printf("1.Push Data\n");
printf("2.Pop Data\n");
printf("3.Print Data\n");
printf("\nPilihan = ");
scanf("%i",&pilihan);
switch(pilihan)
{
case 1:
{
if(tumpuk.atas==5-1)
{
printf("Tumpukan penuh");
getch();
}
else
{
printf("Data yang akan di-push = ");
scanf("%d",&baru);
tumpuk.atas++;
tumpuk.data[tumpuk.atas]=baru;
}
break;
}
case 2:
{
if(tumpuk.atas==-1)
{
printf("Tumpukan kosong");
getch();
}
else
{
printf("Data yang akan di-pop = %d",
tumpuk.data[tumpuk.atas]);
tumpuk.atas--;
getch();
}
break;
}
case 3:
{
if(tumpuk.atas==-1)
{
printf("Tumpukan kosong");
getch();
}
else
{
printf("Data = ");
for(i=0; i<=tumpuk.atas; i++)
{
printf("%d
",tumpuk.data[i]);
}
getch();
}
break;
}
default:
{
printf("\nTidak ada dalam pilihan");
}
}
}while(pilihan>=1 && pilihan<=3);
getch();
}
=========================== SOAL 12
=======================
#include <stdio.h>
#include <conio.h>
#define MAX 8
typedef struct{
int data[MAX];
} Stack;
Stack stack;
int top[2];
void Create(){
//kosongkan stack
top[0] = -1;
top[1] = MAX; //top[1] = 8 karena elemen array 0-7
}
void Tampil(){
int i;
printf("Stack 1\n");
for(i=0;i<=top[0];i++){
printf("%d ",stack.data[i]);
}
printf("\nStack 2\n");
for(i=MAX-1;i>=top[1];i--){
printf("%d ",stack.data[i]);
}
}
void Clear(int noStack){
if(noStack==1) top[0]=-1; else
if(noStack==2) top[1]=MAX;
}
int IsFull(){
int full = 0;
if(top[0]+1 >= top[1]) full=1;
return full;
}
void Push(int d, int noStack){
if(IsFull()==0){
if(noStack == 1) top[0]++; else
if(noStack == 2) top[1]--;
stack.data[top[noStack-1]] = d;
printf("masuk %d !",stack.data[top[noStack-1]]);
}
}
int IsEmpty(int noStack){
int empty=0;
if(noStack==1){
if(top[0] == 0) empty=1;
} else
if(noStack==2){
if(top[1] == MAX) empty=1;
}
return empty;
}
int Pop(int noStack){
int e;
if(IsEmpty(noStack)==0){
e=stack.data[top[noStack-1]];
if(noStack==1) top[0]--; else
if(noStack==2) top[1]++;
}
return e;
}
void Clear(int noStack){
if(noStack==1) top[0]=-1; else
if(noStack==2) top[1]=MAX;
}
void Tampil(){
int i;
printf("Stack 1\n");
for(i=0;i<=top[0];i++){
printf("%d ",stack.data[i]);
}
printf("\nStack 2\n");
for(i=MAX-1;i>=top[1];i--){
printf("%d ",stack.data[i]);
}
}
void main(){
int pil;
int no;
int data;
Create();
do{
clrscr();
printf("1. Push\n");
printf("2. Pop\n");
printf("3. Tampil\n");
printf("4. Clear\n");
printf("5. Exit\n");
printf("Pilihan = ");scanf("%d",&pil);
switch(pil){
case 1: printf("stack ke (1/2) : ");scanf("%d",&no);
printf("Data = ");scanf("%d",&data);
Push(data,no);
break;
case 2: printf("stack ke (1/2) : ");scanf("%d",&no);
printf("Elemen yang keluar : %d",Pop(no));
break;
case 3: Tampil();
break;
case 4: printf("stack ke (1/2) : ");scanf("%d",&no);
Clear(no);
break;
}
getch();
} while(pil!=5);
}
=========================== SOAL 13
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
struct list{
int bil;
struct list * next;
};
typedef struct list NODE;
typedef NODE * PNODE;
PNODE masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE atas=NULL;
PNODE baru;
int pil=1;
clrscr();
while(pil!=4){
cout<<"\n\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=masuk();
PUSH(&atas, baru);
}
if (pil==2)
tampil(atas);
if (pil==3){
POP(&atas);
}
}
}
=========================== SOAL 14
=======================
#include <iostream.h>
#include <string.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
class elemen
{
struct list
{
int bil;
struct list *next;
};
public:
typedef struct list NODE;
typedef NODE *PNODE;
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
if(*atas == NULL)
{
cout<<"\n\nSTACK KOSONG !!!\n\n";
}
else
{
if (PH -> next == NULL)
{
*atas = NULL;
free(PH);
}
else
{
*atas = (*atas) -> next;
free(PH);
}
}
getch();
}
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
*tail = NULL;
free(PH);
}
else
{
*head = (*head) -> next;
free(PH);
}
}
getch();
}
void main()
{
PNODE atas = NULL;
PNODE baru;
PNODE head = NULL,tail = NULL;
int pil=1, x, m;
char *a = "Created bY Tendi Setiadi (6306211) ";
char *b = "Í";
elemen data;
textbackground (RED);
clrscr();
m=strlen(a);
gotoxy (20,20);
for (x=0; x<m; x++)
{
cout<<*(a+x);
delay(200);
}
gotoxy (3,24);
for (x=0; x<75; x++)
{
cout<<*b;
delay(40);
}
while (pil != 3)
{
clrscr();
if (pil == 1)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu STACK <<"<<endl;
cout<<"\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru = data.masuk_stack();
data.PUSH(&atas, baru);
}
if (pil == 2)
data.tampil_stack(atas);
if (pil == 3)
{
data.POP(&atas);
}
}
}
if (pil == 2)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu QUEUE <<"<<endl;
cout<<"\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru=data.masuk_queue();
data.INSERT_QUEUE(&tail,&head,baru);
}
if (pil == 2)
data.tampil_queue(head);
if (pil == 3)
{
data.DELETE_QUEUE(&head,&tail);
}
}
}
}
}
=========================== SOAL 15
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
class elemen{
struct list{
int bil;
struct list * next;
};
public:
typedef struct list NODE;
typedef NODE * PNODE;
PH = *atas;
if(*atas==NULL){
cout<<"\n\nSTACK KOSONG !!!\n\n";
}else{
if (PH->next==NULL){
*atas = NULL;
free(PH);
}else{
*atas = (*atas)->next;
free(PH);
}
}
}
PNODE elemen::masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE atas=NULL;
PNODE baru;
int pil=1;
elemen data;
clrscr();
while(pil!=4){
cout<<"\n\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=data.masuk();
data.PUSH(&atas, baru);
}
if (pil==2)
data.tampil(atas);
if (pil==3){
data.POP(&atas);
}
}
}
=========================== SOAL 16
=======================
=========================== SOAL 17
=======================
=========================== SOAL 18
=======================
=========================== SOAL 19
=======================
=========================== SOAL 20
=======================
=========================== SOAL 21
=======================
=========================== SOAL 22
=======================
=========================== SOAL 23
=======================
=========================== SOAL 24
=======================
=========================== SOAL 25
=======================
=========================== SOAL 26
=======================
=========================== SOAL 27
=======================
=========================== SOAL 28
=======================
=========================== SOAL 29
=======================
=========================== SOAL 30
=======================
=========================== SOAL 31
=======================
=========================== SOAL 32
=======================
=========================== SOAL 33
=======================
=========================== SOAL 34
=======================
=========================== SOAL 35
=======================
=========================== SOAL 36
=======================
=========================== SOAL 37
=======================
=========================== SOAL 38
=======================
=========================== SOAL 39
=======================
=========================== SOAL 40
=======================
=========================== SOAL 41
=======================
=========================== SOAL 42
=======================
=========================== SOAL 43
=======================
=========================== SOAL 44
=======================
=========================== SOAL 45
=======================
=========================== SOAL 46
=======================
=========================== SOAL 47
=======================
=========================== SOAL 48
=======================
=========================== SOAL 49
=======================
=========================== SOAL 50
=======================
===========================================
================
Queue
Queue (Antrian) adalah list linier yang :
1. Dikenali elemen pertama (Head) dan elemen terakhirnya (Tail)
2. Aturan penyisipan dan penghapusan elemennya disefinisikan
sebagai berikut :
- Penyisipan selalu dilakukan setelah elemen terakhir
- Penghapusan selalu dilakukan pada elemen pertama
3. Satu elemen dengan elemen lain dapat diakses melalui
informasi Next
typedef struct
{
char data[MAX];
int head;
int tail;
}Queue;
Queue antrian;
void Create()
{
antrian.head=antrian.tail=-1;
}
int IsEmpty()
{
if(antrian.tail==-1)
return 1;
else
return 0;
int IsFull()
{
if(antrian.tail==MAX-1)
return 1;
else
return 0;
}
int Dequeue()
{
int i;
int e = antrian.data[antrian.head];
for(i=antrian.head;i<=antrian.tail-1;i++)
{
antrian.data[i] = antrian.data[i+1];
}
antrian.tail--;
return e;
}
void Clear()
{
antrian.head=antrian.tail=-1;
printf("data clear");
}
void Tampil()
{
if(IsEmpty()==0)
{
for(int i=antrian.head;i<=antrian.tail;i++)
{
printf("%d ",antrian.data[i]);
}
}
else printf("data kosong!\n");
}
void main()
{
int pil;
char kota[MAX];
Create();
do
{
clrscr();
printf("1. Enqueue\n");
printf("2. Dequeue\n");
printf("3. Tampil\n");
printf("4. Clear\n");
printf("5. Exit\n");
printf("Pilihan = ");scanf("%d",&pil);
switch(pil)
{
case 1:
{
cout<<"Kota = ";
gets(kota);
Enqueue(*kota);
break;
}
case 2:
{
printf("Elemen yang keluar :
%d",Dequeue());
break;
}
case 3: Tampil(); break;
case 4: Clear(); break;
}
getch();
}while(pil!=5);
}
=========================== SOAL 2
=======================
#include <iostream.h>
class element
{
public:
int value;
element* next;
};//class element
class Queue
{
public:
int size;
element* head;
element* tail;
Queue()
{
size=0;
head=NULL;
tail=NULL;
}//default constructor
void Enqueue(int);
void Dequeue();
int isEmpty();
int getQueueSize();
void printQueueSize();
void printQueueElements();
void printQueueMenu();
};
//printQueueElements();
}
void Queue::Dequeue()
{
if(getQueueSize()==0)
return;
else if(head==tail)
{
head=NULL;
}
else
{
element *curr,*prev; //remove the first element inserted and
curr=head; //point the head to next element
head=curr->next;
curr=NULL;
}
size--;
}
int Queue::isEmpty()
{
if(getQueueSize()==0)
return 1;
return 0;
}
int Queue::getQueueSize()
{
return size;
}//returns size of the Queue
void Queue::printQueueSize()
{
cout<<"\nThe Size of the Queue:"<<size<<"\n";
}//print the Queue size
void Queue::printQueueElements()
{
element* curr2;
curr2= head;
cout<<"\n-----\n";
cout<<"Queue\n";
cout<<"-----\n";
cout<<"size:"<<getQueueSize()<<endl;
while(curr2!=NULL)
{
cout<<" |"<<curr2->value<<"|";
curr2=curr2->next;
}
cout<<endl;
}// print the Queue
void Queue::printQueueMenu()
{
cout<<"Welcome to Queue \n";
cout<<"1.Enqueue an element\n";
cout<<"2.Dequeue an element\n";
cout<<"3.Display Queue\n";
cout<<"4.Size Of Queue\n";
cout<<"5.Exit\n";
}
void main()
{
Queue qt;
qt.printQueueMenu();
char Option=0;
int val;
while(1)
{
qt.printQueueMenu();
cin>>Option;
switch(Option)
{
case '1':
cout<<"Enter a Number \n";
cin>>val;
qt.Enqueue(val);
break;
case '2':
qt.Dequeue();
break;
case '3':
qt.printQueueElements();
break;
case '4':
qt.printQueueSize();
break;
case '5':
exit(0);
break;
}
}
}
=========================== SOAL 3
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
struct list{
int bil;
struct list * next;
};
typedef struct list NODE;
typedef NODE * PNODE;
}
}
PNODE masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE head=NULL,tail=NULL;
PNODE baru;
int pil=1;
clrscr();
while(pil!=4){
cout<<"\n\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=masuk();
INSERT_QUEUE(&tail,&head,baru);
}
if (pil==2)
tampil(head);
if (pil==3){
DELETE_QUEUE(&head,&tail);
}
}
}
=========================== SOAL 4
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
struct list{
int bil;
struct list * next;
};
typedef struct list NODE;
typedef NODE * PNODE;
free(PH);
}
}
}
PNODE masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE head=NULL,tail=NULL;
PNODE baru;
int pil=1;
clrscr();
while(pil!=4){
cout<<"\n\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=masuk();
INSERT_QUEUE(&tail,&head,baru);
}
if (pil==2)
tampil(head);
if (pil==3){
DELETE_QUEUE(&head,&tail);
}
}
}
=========================== SOAL 5
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
class elemen{
struct list{
int bil;
struct list * next;
};
public:
typedef struct list NODE;
typedef NODE * PNODE;
PNODE elemen::masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE head=NULL,tail=NULL;
PNODE baru;
int pil=1;
elemen data;
clrscr();
while(pil!=4){
cout<<"\n\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=data.masuk();
data.INSERT_QUEUE(&tail,&head,baru);
}
if (pil==2)
data.tampil(head);
if (pil==3){
data.DELETE_QUEUE(&head,&tail);
}
}
}
=========================== SOAL 6
=======================
#include <iostream.h>
#include <string.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
class elemen
{
struct list
{
int bil;
struct list *next;
};
public:
typedef struct list NODE;
typedef NODE *PNODE;
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
if(*atas == NULL)
{
cout<<"\n\nSTACK KOSONG !!!\n\n";
}
else
{
if (PH -> next == NULL)
{
*atas = NULL;
free(PH);
}
else
{
*atas = (*atas) -> next;
free(PH);
}
}
getch();
}
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
free(PH);
}
else
{
*head = (*head) -> next;
free(PH);
}
}
getch();
}
void main()
{
PNODE atas = NULL;
PNODE baru;
PNODE head = NULL,tail = NULL;
int pil=1, x, m;
char *a = "Created bY Tendi Setiadi (6306211) ";
char *b = "Í";
elemen data;
textbackground (RED);
clrscr();
m=strlen(a);
gotoxy (20,20);
for (x=0; x<m; x++)
{
cout<<*(a+x);
delay(200);
}
gotoxy (3,24);
for (x=0; x<75; x++)
{
cout<<*b;
delay(40);
}
while (pil != 3)
{
clrscr();
cout<<"\n-> Menu Utama <-"<<endl;
cout<<"\n1> Stack";
cout<<"\n2> Queue";
cout<<"\n3> Exit";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu STACK <<"<<endl;
cout<<"\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru = data.masuk_stack();
data.PUSH(&atas, baru);
}
if (pil == 2)
data.tampil_stack(atas);
if (pil == 3)
{
data.POP(&atas);
}
}
}
if (pil == 2)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu QUEUE <<"<<endl;
cout<<"\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru=data.masuk_queue();
data.INSERT_QUEUE(&tail,&head,baru);
}
if (pil == 2)
data.tampil_queue(head);
if (pil == 3)
{
data.DELETE_QUEUE(&head,&tail);
}
}
}
}
}
=========================== SOAL 7
=======================
#include <stdio.h>
#include <malloc.h>
#include <string.h>
//----------------------
struct nilaiMatKul{
char nim[10];
char nama[50];
float nilai;
};
struct elemen{
nilaiMatKul elmt;
struct elemen *next;
};
struct queue{
struct elemen *first;
struct elemen *last;
};
//----------------------
//----------------------
return hasil;
}
//----------------------
if(Q.first != NULL){
/* queue tidak kosong */
elemen *elmt;
/* inisialisasi */
elmt = Q.first;
while(elmt != NULL){
/* proses */
hasil= hasil + 1;
/* iterasi */
elmt = elmt->next;
}
}
return hasil;
}
//----------------------
//----------------------
//----------------------
while(elmt != NULL){
printf("====================\n");
printf("elemen ke : %d\n", i);
printf("nim : %s\n", elmt->elmt.nim);
printf("nama : %s\n", elmt->elmt.nama);
printf("nilai : %f\n", elmt->elmt.nilai);
/* iterasi */
elmt = elmt->next;
i = i + 1;
}
printf("---------------------\n");
}
else{
/* proses jika queue kosong */
printf("queue kosong\n");
}
}
//----------------------
int main(){
struct queue Q;
createEmpty(&Q);
printQueue(Q);
printf("=================\n");
add("13507701", "Imam", 64.75, &Q);
add("13507702", "Cinta", 75.11, &Q);
add("13507703", "Jasmine", 84.63, &Q);
printQueue(Q);
printf("=================\n");
del(&Q);
del(&Q);
printQueue(Q);
printf("=================\n");
return 0;
=========================== SOAL 8
=======================
#include <stdio.h>
#include <string.h>
//----------------------
struct nilaiMatKul{
char nim[10];
char nama[50];
float nilai;
};
struct queue{
int first;
int last;
nilaiMatKul data[10];
};
//----------------------
(*Q).first = -1;
(*Q).last = -1;
}
//----------------------
if(Q.first == -1){
hasil = true;
}
return hasil;
}
//----------------------
//----------------------
if(isEmpty(*Q) == true){
/* jika queue kosong */
(*Q).first = 0;
(*Q).last = 0;
strcpy((*Q).data[0].nim, nim);
strcpy((*Q).data[0].nama, nama);
(*Q).data[0].nilai = nilai;
}
else{
/* jika queue tidak kosong */
if(isFull(*Q) != true){
(*Q).last = (*Q).last + 1;
strcpy((*Q).data[(*Q).last].nim, nim);
strcpy((*Q).data[(*Q).last].nama, nama);
(*Q).data[(*Q).last].nilai = nilai;
}
else{
printf("queue penuh\n");
}
}
}
//----------------------
//----------------------
//----------------------
int main(){
queue Q;
createEmpty(&Q);
printQueue(Q);
printf("=================\n");
printf("=================\n");
del(&Q);
del(&Q);
printQueue(Q);
printf("=================\n");
return 0;
}
=========================== SOAL 9
=======================
#include <stdio.h>
#define MAX 10 /* The maximum size of the queue */
#include <stdlib.h>
void main()
{
int queue[MAX];
int front,rear;
int n,value;
front=rear=(-1);
do
{
do
{
printf("Enter the element to be inserted\n");
scanf("%d",&value);
insert(queue,&rear,value);
printf("Enter 1 to continue\n");
scanf("%d",&n);
} while(n == 1);
if(*rear == front)
{
printf("The queue is full can not insert a value\n");
exit(0);
}
queue[*rear] = value;
}
void main()
{
int queue[MAX];
int front,rear;
int n,value;
front=0; rear=0;
do
{
do
{
printf("Enter the element to be inserted\n");
scanf("%d",&value);
insert(queue,&rear,front,value);
printf("Enter 1 to continue\n");
scanf("%d",&n);
} while(n == 1);
# include <stdlib.h>
struct node
{
int data;
struct node *link;
};
void main()
{
struct node *front=NULL,*rear = NULL;
int n,value;
do
{
do
{
printf("Enter the element to be inserted\n");
scanf("%d",&value);
insert(&front,&rear,value);
printf("Enter 1 to continue\n");
scanf("%d",&n);
} while(n == 1);
*front = *rear;
}
else
{
if((*front)->priority < priority)
/* the element to be inserted has
highest priority hence should
be the first element*/
{
temp->link = *front;
*front = temp;
}
else
if( (*rear)->priority > priority)
/* the element to be inserted has
lowest priority hence should
be the last element*/
{
(*rear)->link = temp;
*rear = temp;
}
else
{
temp1 = *front;
while((temp1->link)->priority >= priority)
/* find the position and insert the new element */
temp1=temp1->link;
temp->link = temp1->link;
temp1->link = temp;
}
}
void delete(struct node **front, struct node **rear, int *value,
int *priority)
{
struct node *temp;
if((*front == *rear) && (*rear == NULL))
{
printf(" The queue is empty cannot delete Error\n");
exit(0);
}
*value = (*front)->data;
*priority = (*front)->priority;
temp = *front;
*front = (*front)->link;
if(*rear == temp)
*rear = (*rear)->link;
free(temp);
}
void main()
{
struct node *front=NULL,*rear = NULL;
Enqueue(data);
break;
case 2: printf("Elemen yang keluar : %d",Dequeue());
break;
case 3: Tampil();
break;
case 4: Clear();
break;
}
getch();
} while(pil!=5);
}
=========================== SOAL 14
=======================
#include <LTime.h>
#include <Queue.h>
#include <iostream.h>
#include <dos.h>
#include <stdlib.h>
int main()
{
int k;
Queue timeLine;
cout << "\nSampling";
for( int i = 0; i < 7; i++ )
{
struct time snapShot;
gettime( &snapShot );
Time sample( snapShot.ti_hour,
snapShot.ti_min,
snapShot.ti_sec,
snapShot.ti_hund );
timeLine.put ( *(new Time( sample )) );
cout << ".";
randomize();
k = rand();
for(int j = 0; j < k; ++j ) // Delay loop
{
cout << "";
}
}
cout << "\nThe timing samples are:\n\n";
while( !timeLine.isEmpty() )
{
Time& sampleTime = (Time&)timeLine.get();
cout << sampleTime << "\n";
delete &sampleTime;
}
return 0;
}
=========================== SOAL 15
=======================
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#define MAX 8
typedef struct
{
char data[MAX];
int head;
int tail;
}Queue;
Queue antrian;
void Create()
{
antrian.head=antrian.tail=-1;
}
int IsEmpty()
{
if(antrian.tail==-1)
return 1;
else
return 0;
}
int IsFull()
{
if(antrian.tail==MAX-1)
return 1;
else
return 0;
}
int Dequeue()
{
int i;
int e = antrian.data[antrian.head];
for(i=antrian.head;i<=antrian.tail-1;i++)
{
antrian.data[i] = antrian.data[i+1];
}
antrian.tail--;
return e;
}
void Clear()
{
antrian.head=antrian.tail=-1;
printf("data clear");
}
void Tampil()
{
if(IsEmpty()==0)
{
for(int i=antrian.head;i<=antrian.tail;i++)
{
printf("%d ",antrian.data[i]);
}
}
else printf("data kosong!\n");
}
void main()
{
int pil;
char kota[MAX];
Create();
do
{
clrscr();
printf("1. Enqueue\n");
printf("2. Dequeue\n");
printf("3. Tampil\n");
printf("4. Clear\n");
printf("5. Exit\n");
printf("Pilihan = ");scanf("%d",&pil);
switch(pil)
{
case 1:
{
cout<<"Kota = ";
gets(kota);
Enqueue(*kota);
break;
}
case 2:
{
printf("Elemen yang keluar :
%d",Dequeue());
break;
}
case 3: Tampil(); break;
case 4: Clear(); break;
}
getch();
}while(pil!=5);
}
=========================== SOAL 16
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
class elemen{
struct list{
char kota[30];
struct list * next;
};
public:
typedef struct list NODE;
typedef NODE * PNODE;
void tampil(PNODE head);
void INSERT_QUEUE(PNODE *tail,PNODE *head, PNODE baru);
void DELETE_QUEUE(PNODE *head, PNODE *tail);
void PUSH(PNODE *head, PNODE baru);
void POP(PNODE *head);
PNODE masuk(void);
}data;
PNODE elemen::masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nKota : ";cin>>baru->kota;
baru->next=NULL;
return(baru);
}
void main(){
PNODE head=NULL,tail=NULL;
PNODE baru;
int pil=1,cari=1;
clrscr();
while(pil!=4){
clrscr();
cout<<"\n\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
cout<<"\n\n1. Insert Queue";
cout<<"\n2. Insert Stack";
cout<<"\nPilih ? ";
cin>>cari;
baru=data.masuk();
if(cari==1)
{
data.INSERT_QUEUE(&tail,&head,baru);
}
if(cari==2){
data.PUSH(&head, baru);
}
}
if (pil==2)
data.tampil(head);
getch();
if (pil==3){
cout<<"\n\n1. Delete Queue";
cout<<"\n2. Delete stack";
cout<<"\nPilih ? ";
cin>>cari;
if(cari==1){
data.DELETE_QUEUE(&head,&tail);
}
if(cari==2){
data.POP(&head);
}
}
}
=========================== SOAL 17
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
struct list{
int bil;
struct list * next;
};
typedef struct list NODE;
typedef NODE * PNODE;
PNODE masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE head=NULL,tail=NULL;
PNODE baru;
int pil=1;
clrscr();
while(pil!=4){
cout<<"\n\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=masuk();
INSERT_QUEUE(&tail,&head,baru);
}
if (pil==2)
tampil(head);
if (pil==3){
DELETE_QUEUE(&head,&tail);
}
}
}
=========================== SOAL 18
=======================
#include <iostream.h>
#include <string.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
class elemen
{
struct list
{
int bil;
struct list *next;
};
public:
typedef struct list NODE;
typedef NODE *PNODE;
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
if(*atas == NULL)
{
cout<<"\n\nSTACK KOSONG !!!\n\n";
}
else
{
if (PH -> next == NULL)
{
*atas = NULL;
free(PH);
}
else
{
*atas = (*atas) -> next;
free(PH);
}
}
getch();
}
while(pos != NULL)
{
cout<<pos -> bil<<", ";
pos = pos -> next;
}
cout<<"\n\n\n [TEKAN ENTER UNTUK MELANJUTKAN]";
getch();
}
{
cout<<"\n\nQUEUE KOSONG !!!\n\n";
}
else
{
if (PH -> next == NULL)
{
*head = NULL;
*tail = NULL;
free(PH);
}
else
{
*head = (*head) -> next;
free(PH);
}
}
getch();
}
void main()
{
PNODE atas = NULL;
PNODE baru;
PNODE head = NULL,tail = NULL;
int pil=1, x, m;
char *a = "Created bY Tendi Setiadi (6306211) ";
char *b = "Í";
elemen data;
textbackground (RED);
clrscr();
m=strlen(a);
gotoxy (20,20);
for (x=0; x<m; x++)
{
cout<<*(a+x);
delay(200);
}
gotoxy (3,24);
for (x=0; x<75; x++)
{
cout<<*b;
delay(40);
}
while (pil != 3)
{
clrscr();
cout<<"\n-> Menu Utama <-"<<endl;
cout<<"\n1> Stack";
cout<<"\n2> Queue";
cout<<"\n3> Exit";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu STACK <<"<<endl;
cout<<"\n1. PUSH STACK";
cout<<"\n2. LIHAT DATA STACK";
cout<<"\n3. POP STACK";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru = data.masuk_stack();
data.PUSH(&atas, baru);
}
if (pil == 2)
data.tampil_stack(atas);
if (pil == 3)
{
data.POP(&atas);
}
}
}
if (pil == 2)
{
while(pil != 4)
{
clrscr();
cout<<"\n>> Menu QUEUE <<"<<endl;
cout<<"\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. Menu Utama";
cout<<"\nPilihan : ";cin>>pil;
if (pil == 1)
{
baru=data.masuk_queue();
data.INSERT_QUEUE(&tail,&head,baru);
}
if (pil == 2)
data.tampil_queue(head);
if (pil == 3)
{
data.DELETE_QUEUE(&head,&tail);
}
}
}
}
}
=========================== SOAL 19
=======================
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
class elemen{
struct list{
int bil;
struct list * next;
};
public:
typedef struct list NODE;
typedef NODE * PNODE;
*head = baru;
*tail = baru;
}else{
(*tail)->next = baru;
*tail = baru;
}
}
PNODE elemen::masuk(void){
PNODE baru;
baru=(NODE *)malloc(sizeof(NODE));
cout<<"\nbil : ";cin>>baru->bil;
baru->next=NULL;
return(baru);
}
void main(){
PNODE head=NULL,tail=NULL;
PNODE baru;
int pil=1;
elemen data;
clrscr();
while(pil!=4){
cout<<"\n\n1. INSERT_QUEUE LIST";
cout<<"\n2. LIHAT DATA LIST";
cout<<"\n3. DELETE_QUEUE LIST";
cout<<"\n4. EXIT";
cout<<"\nPilihan : ";cin>>pil;
if (pil==1){
baru=data.masuk();
data.INSERT_QUEUE(&tail,&head,baru);
}
if (pil==2)
data.tampil(head);
if (pil==3){
data.DELETE_QUEUE(&head,&tail);
}
}
}
=========================== SOAL 20
=======================
=========================== SOAL 21
=======================
=========================== SOAL 22
=======================
=========================== SOAL 23
=======================
=========================== SOAL 24
=======================
=========================== SOAL 25
=======================
=========================== SOAL 26
=======================
=========================== SOAL 27
=======================
=========================== SOAL 28
=======================
=========================== SOAL 29
=======================
=========================== SOAL 30
=======================
=========================== SOAL 31
=======================
=========================== SOAL 32
=======================
=========================== SOAL 33
=======================
=========================== SOAL 34
=======================
=========================== SOAL 35
=======================
=========================== SOAL 36
=======================
=========================== SOAL 37
=======================
=========================== SOAL 38
=======================
=========================== SOAL 39
=======================
=========================== SOAL 40
=======================
=========================== SOAL 41
=======================
=========================== SOAL 42
=======================
=========================== SOAL 43
=======================
=========================== SOAL 44
=======================
=========================== SOAL 45
=======================
=========================== SOAL 46
=======================
=========================== SOAL 47
=======================
=========================== SOAL 48
=======================
=========================== SOAL 49
=======================
=========================== SOAL 50
=======================
===========================================
================