Program kali ini cukup istimewa karena menggunakan class sebagai dasar dari OOP(Object Oriented Programing) berikut source code dari program queue menggunakan linked list.
#include <iostream.h>
#include <conio.h>
class linked_list_queue{
private:
struct node{
int data;
node *next;
};
node *rear;
node *entry;
node *print;
node *front;
public:
linked_list_queue();
void enqueue();
void dequeue();
void print_list();
};
linked_list_queue::linked_list_queue(){
rear=NULL;
front=NULL;
}
void linked_list_queue::enqueue(){
int angka;
cout<<'masukkan angka kedalam queue:';cin>>angka;
entry=new node;
if(rearNULL){
entry->data=angka;
entry->next=NULL;
rear=entry;
front=rear;
}
else{
entry->data=angka;
entry->next=NULL;
rear->next=entry;
rear=entry;
}
cout<<endl;
cout<<'data '<<angka<<' telah masuk';
getch();
}
void linked_list_queue::dequeue(){
if(frontNULL){
cout<<'queue kosong';cout<<endl;
}
else{
int deleted_element=front->data;
node *temp;
temp=front;
front=front->next;
delete temp;
cout<<deleted_element<<' telah dihapus';
cout<<endl;
}
getch();
}
void linked_list_queue::print_list(){
print=front;
if(print!=NULL){
cout<<'angka dalam queue:';
}
else{
cout<<'queue kosong';cout<<endl;
}
while(print!=NULL){
cout<<print->data;
print=print->next;
}
getch();
}
main(){
int pilih;
linked_list_queue queue;
do{
clrscr();
cout<<'1.enqueue data'<<endl;
cout<<'2.dequeue data'<<endl;
cout<<'3.tampilkan data'<<endl;
cout<<'masukkan pilihan:';cin>>pilih;cout<<endl;
if(pilih1){
queue.enqueue();
}
if(pilih2){
queue.dequeue();
}
if(pilih3){
queue.print_list();
}
}
while(pilih!=0||pilih>3);
getch();
Dec 30, 2016 Mahir Koding – Queue adalah bentuk lain dari konsep implementasi linked list. Berbeda dengan Stack, yang menerapkan konsep LIFO (Last In First Out), Queue justru mempunyai konsep yang berbeda yakni FIFO (First In First Out). Setiap data yang pertama kali masuk, dialah yang akan keluar duluan. R studio data recovery software 5.3 keygen. Word for mac shortcuts insert picture from file. Linked list merupakan struktur data (bertipe sama, Lihat: Struct (Struktur) dalam Bahasa C) yang terdiri sekumpulan node yang secara bersama-sama merepresentasikan sebuah urutan. Autodesk inventor professional 2013 full crack software. Lie detector software free for pc. Linked list juga disebut sebuah metode untuk menyimpan data dengan struktur sehingga dapat secara otomatis menciptakan suatu tempat di memory untuk menyimpan data yang. Day of infamy coop. Adobe flash player 10 mac.
#include <iostream.h>
#include <conio.h>
class linked_list_queue{
private:
struct node{
int data;
node *next;
};
node *rear;
node *entry;
node *print;
node *front;
public:
linked_list_queue();
void enqueue();
void dequeue();
void print_list();
};
linked_list_queue::linked_list_queue(){
rear=NULL;
front=NULL;
}
void linked_list_queue::enqueue(){
int angka;
cout<<'masukkan angka kedalam queue:';cin>>angka;
entry=new node;
if(rearNULL){
entry->data=angka;
entry->next=NULL;
rear=entry;
front=rear;
}
else{
entry->data=angka;
entry->next=NULL;
rear->next=entry;
rear=entry;
}
cout<<endl;
cout<<'data '<<angka<<' telah masuk';
getch();
}
void linked_list_queue::dequeue(){
if(frontNULL){
cout<<'queue kosong';cout<<endl;
}
else{
int deleted_element=front->data;
node *temp;
temp=front;
front=front->next;
delete temp;
cout<<deleted_element<<' telah dihapus';
cout<<endl;
}
getch();
}
void linked_list_queue::print_list(){
print=front;
if(print!=NULL){
cout<<'angka dalam queue:';
}
else{
cout<<'queue kosong';cout<<endl;
}
while(print!=NULL){
cout<<print->data;
print=print->next;
}
getch();
}
main(){
int pilih;
linked_list_queue queue;
do{
clrscr();
cout<<'1.enqueue data'<<endl;
cout<<'2.dequeue data'<<endl;
cout<<'3.tampilkan data'<<endl;
cout<<'masukkan pilihan:';cin>>pilih;cout<<endl;
if(pilih1){
![Contoh program queue dengan linked list youtube Contoh program queue dengan linked list youtube](https://kuliahinformatika.files.wordpress.com/2010/04/evans-blog-praktikum-struktur-data-bahasa-java-implementasi-prefix-sufix.jpg)
}
if(pilih2){
queue.dequeue();
}
if(pilih3){
queue.print_list();
}
}
while(pilih!=0||pilih>3);
getch();