SlideShare une entreprise Scribd logo
1  sur  7
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#define MAX 6
typedef struct
{
int 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;
}
void enqueue(int data)
{
if(isempty()==1)
{
antrian.head=antrian.tail=0;
antrian.data[antrian.tail]=data;
printf("%d, Sudah Masuk!",antrian.data[antrian.tail]);
void tampil();
{
int i;
if (isempty()==0)
{
for(i=antrian.head;i<=antrian.tail;i++)
{
printf(" %d ",antrian.data[i]);
}
}
else
printf("n**** QUEUE IS EMPTY ****n");
}
}
else
if(isfull()==0)
{
antrian.tail++;
antrian.data[antrian.tail]=data;
printf("%d , Sudah Masuk!",antrian.data[antrian.tail]);
}
else{
if(isfull()==1)
{
cout<<"nn**** QUEUE IS FULL , data TIDAK dapat masuk ****";
}
}
gotoxy(25,8);cout<<"PRESS any key for back to MENU";
}
int dequeue()
{
if (isempty()==1){
cout<<"n**** ERROR :: QUEUE IS EMPTY ****";
}else
if(isempty()==0){
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--;
cout<<"nnData Yang Keluar => "<<e;
}
gotoxy(25,8);cout<<"PRESS any key for back to MENU";
}
void clear()
{
antrian.head=antrian.tail=-1;
printf("nn**** DATA CLEAR ****");
gotoxy(25,8);cout<<"PRESS any key for back to MENU";
}
void tampil()
{
int i;
if(isempty()==0)
{
cout<<"Data Yang ada Dalam QUEUE : "<<endl<<endl;
for(i=antrian.head;i<=antrian.tail;i++)
{
printf("| %d |",antrian.data[i]);
}
}
else
{
printf("n**** QUEUE IS EMPTY ****n");
}
gotoxy(25,8);cout<<"PRESS any key for back to MENU";
}
void main()
{
int pil;
int data;
create();
do
{
clrscr();
gotoxy(25,2);cout<<"========MENU PILIHAN========"<<endl<<endl;
gotoxy(25,4);cout<<"============================"<<endl;
gotoxy(30,6);cout<<" 1. ENQUEUE "<<endl;
gotoxy(30,7);cout<<" 2. DEQUEUE "<<endl;
gotoxy(30,8);cout<<" 3. TAMPILAN "<<endl;
gotoxy(30,9);cout<<" 4. CLEAR "<<endl;
gotoxy(30,10);cout<<" 5. KELUAR "<<endl;
gotoxy(25,12);cout<<"============================"<<endl;
gotoxy(25,14);cout<<" Masukan Pilihan Anda => ";cin>>pil;
switch(pil){
case 1:
clrscr();
printf("nn Masukan Data => "); scanf("%d",&data);
enqueue(data);
break;
case 2:
clrscr();
dequeue();
break;
case 3:
clrscr();
cout<<endl;
tampil();
break;
case 4:
clrscr();
clear();
break;
case 5:
clrscr();
gotoxy(25,8);cout<<"**** TERIMA KASIH ****"<<endl;
break;
}
getch();
} while(pil!=5);
}

Contenu connexe

Tendances

Masa balita, masa kanak kanak, masa remaja
Masa balita, masa kanak kanak, masa remajaMasa balita, masa kanak kanak, masa remaja
Masa balita, masa kanak kanak, masa remajadiah_nahdhiah_35
 
Bab 3 Jaringan Hewan - Kelas XI - SMAN 5 Yogyakarta
Bab 3 Jaringan Hewan - Kelas XI - SMAN 5 YogyakartaBab 3 Jaringan Hewan - Kelas XI - SMAN 5 Yogyakarta
Bab 3 Jaringan Hewan - Kelas XI - SMAN 5 YogyakartaResma Puspitasari
 
Berpikir
BerpikirBerpikir
Berpikirvera78
 
Materi Basis Data - Anomali dan Normalisasi
Materi Basis Data - Anomali dan NormalisasiMateri Basis Data - Anomali dan Normalisasi
Materi Basis Data - Anomali dan NormalisasiDerina Ellya R
 
Tugas 2 individu tentang dbms
Tugas 2 individu tentang dbmsTugas 2 individu tentang dbms
Tugas 2 individu tentang dbmsElma Fiana
 
Teori kepribadian Carl R. Rogers
Teori kepribadian Carl R. RogersTeori kepribadian Carl R. Rogers
Teori kepribadian Carl R. RogersAi Nurhasanah
 
Silogisme hipotesis
Silogisme hipotesisSilogisme hipotesis
Silogisme hipotesisFuji Lestari
 
Ragam bahasa berdasarkan situasi pemakaian
Ragam bahasa berdasarkan situasi pemakaianRagam bahasa berdasarkan situasi pemakaian
Ragam bahasa berdasarkan situasi pemakaianRipan Nugraha Harahap
 
Pertemuan 2-pemecahan-masalah-ai
Pertemuan 2-pemecahan-masalah-aiPertemuan 2-pemecahan-masalah-ai
Pertemuan 2-pemecahan-masalah-aiwillyhayon
 
Materi Struktur Data Tree
Materi Struktur Data TreeMateri Struktur Data Tree
Materi Struktur Data TreeMeta N
 
Makalah array
Makalah arrayMakalah array
Makalah arrayAnanda II
 

Tendances (20)

Modul 4 ragam bahasa.
Modul 4   ragam bahasa.Modul 4   ragam bahasa.
Modul 4 ragam bahasa.
 
Masa balita, masa kanak kanak, masa remaja
Masa balita, masa kanak kanak, masa remajaMasa balita, masa kanak kanak, masa remaja
Masa balita, masa kanak kanak, masa remaja
 
Bab 3 Jaringan Hewan - Kelas XI - SMAN 5 Yogyakarta
Bab 3 Jaringan Hewan - Kelas XI - SMAN 5 YogyakartaBab 3 Jaringan Hewan - Kelas XI - SMAN 5 Yogyakarta
Bab 3 Jaringan Hewan - Kelas XI - SMAN 5 Yogyakarta
 
Tahap perkembangan moral kohlberg
Tahap perkembangan moral kohlbergTahap perkembangan moral kohlberg
Tahap perkembangan moral kohlberg
 
Enzim katalase biologi sma n 1 simo boyolal1
Enzim katalase biologi sma n 1 simo boyolal1Enzim katalase biologi sma n 1 simo boyolal1
Enzim katalase biologi sma n 1 simo boyolal1
 
Berpikir
BerpikirBerpikir
Berpikir
 
Materi Basis Data - Anomali dan Normalisasi
Materi Basis Data - Anomali dan NormalisasiMateri Basis Data - Anomali dan Normalisasi
Materi Basis Data - Anomali dan Normalisasi
 
Tugas 2 individu tentang dbms
Tugas 2 individu tentang dbmsTugas 2 individu tentang dbms
Tugas 2 individu tentang dbms
 
SUBSTANSI GENETIKA BIOLOGI
SUBSTANSI GENETIKA BIOLOGISUBSTANSI GENETIKA BIOLOGI
SUBSTANSI GENETIKA BIOLOGI
 
Deuteromycota
Deuteromycota Deuteromycota
Deuteromycota
 
Teori kepribadian Carl R. Rogers
Teori kepribadian Carl R. RogersTeori kepribadian Carl R. Rogers
Teori kepribadian Carl R. Rogers
 
Oracle transaksi
Oracle transaksiOracle transaksi
Oracle transaksi
 
Database security (ppt)
Database security (ppt)Database security (ppt)
Database security (ppt)
 
Silogisme hipotesis
Silogisme hipotesisSilogisme hipotesis
Silogisme hipotesis
 
Ragam bahasa berdasarkan situasi pemakaian
Ragam bahasa berdasarkan situasi pemakaianRagam bahasa berdasarkan situasi pemakaian
Ragam bahasa berdasarkan situasi pemakaian
 
Proses berfikir kreatif
Proses berfikir kreatifProses berfikir kreatif
Proses berfikir kreatif
 
Pertemuan 2-pemecahan-masalah-ai
Pertemuan 2-pemecahan-masalah-aiPertemuan 2-pemecahan-masalah-ai
Pertemuan 2-pemecahan-masalah-ai
 
Anatomi Tumbuhan - Reproduksi Sel
Anatomi Tumbuhan - Reproduksi SelAnatomi Tumbuhan - Reproduksi Sel
Anatomi Tumbuhan - Reproduksi Sel
 
Materi Struktur Data Tree
Materi Struktur Data TreeMateri Struktur Data Tree
Materi Struktur Data Tree
 
Makalah array
Makalah arrayMakalah array
Makalah array
 

Similaire à contoh Program queue

Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligenceAditya Sharma
 
i am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdfi am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdfANJALIENTERPRISES1
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresLakshmi Sarvani Videla
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manualSANTOSH RATH
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderSamsil Arefin
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfapexelectronices01
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 

Similaire à contoh Program queue (20)

Sorting programs
Sorting programsSorting programs
Sorting programs
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
i am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdfi am using C++ codingsource coding Program that sorts an arra.pdf
i am using C++ codingsource coding Program that sorts an arra.pdf
 
C program
C programC program
C program
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
Pnno
PnnoPnno
Pnno
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
Program to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical orderProgram to sort the n names in an alphabetical order
Program to sort the n names in an alphabetical order
 
Data structures
Data structuresData structures
Data structures
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdf
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Ds
DsDs
Ds
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 

Plus de Bina Sarana Informatika (20)

ANALISA DAN PERANCANGAN SISTEM INFORMASI
ANALISA DAN PERANCANGAN SISTEM INFORMASI ANALISA DAN PERANCANGAN SISTEM INFORMASI
ANALISA DAN PERANCANGAN SISTEM INFORMASI
 
948 p06
948 p06948 p06
948 p06
 
948 p05
948 p05 948 p05
948 p05
 
948 p04
948 p04948 p04
948 p04
 
948 p02
948 p02 948 p02
948 p02
 
948 p01
948 p01 948 p01
948 p01
 
948 p03
948 p03 948 p03
948 p03
 
948 p06
948 p06948 p06
948 p06
 
948 p05
948 p05948 p05
948 p05
 
948 p04
948 p04948 p04
948 p04
 
948 p03
948 p03948 p03
948 p03
 
948 p02
948 p02948 p02
948 p02
 
948 p01
948 p01948 p01
948 p01
 
948 ltm metode penelitian - 3 sks
948 ltm metode penelitian - 3 sks948 ltm metode penelitian - 3 sks
948 ltm metode penelitian - 3 sks
 
Kuiz dasar manajemen bisnis pert 9 14
Kuiz dasar manajemen bisnis pert 9 14Kuiz dasar manajemen bisnis pert 9 14
Kuiz dasar manajemen bisnis pert 9 14
 
Silabus bahasa inggris ii
Silabus bahasa inggris iiSilabus bahasa inggris ii
Silabus bahasa inggris ii
 
Silabus bahasa inggris ii ok
Silabus bahasa inggris ii okSilabus bahasa inggris ii ok
Silabus bahasa inggris ii ok
 
Meeting 14 ok
Meeting 14 okMeeting 14 ok
Meeting 14 ok
 
Meeting 12 ok
Meeting 12 okMeeting 12 ok
Meeting 12 ok
 
Meeting 10 ok
Meeting 10 okMeeting 10 ok
Meeting 10 ok
 

Dernier

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Dernier (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

contoh Program queue

  • 1. #include <stdio.h> #include <conio.h> #include <iostream.h> #define MAX 6 typedef struct { int 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; }
  • 2. int isfull() { if(antrian.tail==MAX-1) return 1; else return 0; } void enqueue(int data) { if(isempty()==1) { antrian.head=antrian.tail=0; antrian.data[antrian.tail]=data; printf("%d, Sudah Masuk!",antrian.data[antrian.tail]); void tampil(); { int i; if (isempty()==0) { for(i=antrian.head;i<=antrian.tail;i++) { printf(" %d ",antrian.data[i]); } }
  • 3. else printf("n**** QUEUE IS EMPTY ****n"); } } else if(isfull()==0) { antrian.tail++; antrian.data[antrian.tail]=data; printf("%d , Sudah Masuk!",antrian.data[antrian.tail]); } else{ if(isfull()==1) { cout<<"nn**** QUEUE IS FULL , data TIDAK dapat masuk ****"; } } gotoxy(25,8);cout<<"PRESS any key for back to MENU"; } int dequeue() { if (isempty()==1){ cout<<"n**** ERROR :: QUEUE IS EMPTY ****";
  • 4. }else if(isempty()==0){ 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--; cout<<"nnData Yang Keluar => "<<e; } gotoxy(25,8);cout<<"PRESS any key for back to MENU"; } void clear() { antrian.head=antrian.tail=-1; printf("nn**** DATA CLEAR ****"); gotoxy(25,8);cout<<"PRESS any key for back to MENU"; } void tampil() { int i; if(isempty()==0)
  • 5. { cout<<"Data Yang ada Dalam QUEUE : "<<endl<<endl; for(i=antrian.head;i<=antrian.tail;i++) { printf("| %d |",antrian.data[i]); } } else { printf("n**** QUEUE IS EMPTY ****n"); } gotoxy(25,8);cout<<"PRESS any key for back to MENU"; } void main() { int pil; int data; create(); do { clrscr(); gotoxy(25,2);cout<<"========MENU PILIHAN========"<<endl<<endl; gotoxy(25,4);cout<<"============================"<<endl; gotoxy(30,6);cout<<" 1. ENQUEUE "<<endl;
  • 6. gotoxy(30,7);cout<<" 2. DEQUEUE "<<endl; gotoxy(30,8);cout<<" 3. TAMPILAN "<<endl; gotoxy(30,9);cout<<" 4. CLEAR "<<endl; gotoxy(30,10);cout<<" 5. KELUAR "<<endl; gotoxy(25,12);cout<<"============================"<<endl; gotoxy(25,14);cout<<" Masukan Pilihan Anda => ";cin>>pil; switch(pil){ case 1: clrscr(); printf("nn Masukan Data => "); scanf("%d",&data); enqueue(data); break; case 2: clrscr(); dequeue(); break; case 3: clrscr(); cout<<endl; tampil(); break;
  • 7. case 4: clrscr(); clear(); break; case 5: clrscr(); gotoxy(25,8);cout<<"**** TERIMA KASIH ****"<<endl; break; } getch(); } while(pil!=5); }