#include <iostream.h>
#include <conio.h>
main()
{
int cek=0, data[20], x, hapus;
char pil;
do {
clrscr();
cout<<"1. Tambah Antrian"<<endl;
cout<<"2. Hapus Antrian"<<endl;
cout<<"3. Lihat Antrian"<<endl;
cout<<"4. Keluar"<<endl;
cout<<endl;
cout<<"Silahkan masukkan pilihan anda = ";
pil=getche();
cout<<endl;
if(pil!='1' && pil !='2' && pil !='3' && pil!='4' )
cout<<"Anda salah mengetikkan inputan";
else
{
if(pil=='1') //PUSH
{
if(cek==20)
cout<<"Antrian Penuh";
else
{
cout<<"Masukkan nilai = ";
cin>>x;
data[cek]=x;
cek++;
}
}
else
{
if(pil=='2') //POP
{
if(cek==0)
cout<<"Antrian kosong";
else
{
hapus=data[0];
for(int v=0;v<cek;v++)
data[v]=data[v+1];
data[cek-1]=NULL;
cek--;
cout<<"Data dengan nilai "<<hapus<<" terhapus";
}
getch();
}
else
{
if(pil=='3') //CEK DATA
{
if(cek==0)
cout<<"Antrian Kosong";
else
{
cout<<endl;
for(int z=0;z<cek;z++)
{
cout<<" | ";
cout<<" "<<data[z];
cout<<" | ";
}
}
getch();
}
}
}
}
}while(pil!='4');
}
#include <conio.h>
main()
{
int cek=0, data[20], x, hapus;
char pil;
do {
clrscr();
cout<<"1. Tambah Antrian"<<endl;
cout<<"2. Hapus Antrian"<<endl;
cout<<"3. Lihat Antrian"<<endl;
cout<<"4. Keluar"<<endl;
cout<<endl;
cout<<"Silahkan masukkan pilihan anda = ";
pil=getche();
cout<<endl;
if(pil!='1' && pil !='2' && pil !='3' && pil!='4' )
cout<<"Anda salah mengetikkan inputan";
else
{
if(pil=='1') //PUSH
{
if(cek==20)
cout<<"Antrian Penuh";
else
{
cout<<"Masukkan nilai = ";
cin>>x;
data[cek]=x;
cek++;
}
}
else
{
if(pil=='2') //POP
{
if(cek==0)
cout<<"Antrian kosong";
else
{
hapus=data[0];
for(int v=0;v<cek;v++)
data[v]=data[v+1];
data[cek-1]=NULL;
cek--;
cout<<"Data dengan nilai "<<hapus<<" terhapus";
}
getch();
}
else
{
if(pil=='3') //CEK DATA
{
if(cek==0)
cout<<"Antrian Kosong";
else
{
cout<<endl;
for(int z=0;z<cek;z++)
{
cout<<" | ";
cout<<" "<<data[z];
cout<<" | ";
}
}
getch();
}
}
}
}
}while(pil!='4');
}
4 comments
Click here for commentsthank's bgt neeh wt listingnya...membantu bgt u/ balajar...
Replythanks brothers lagi belajar ini c++ :)
Replymakasih ya, sangat bermanfaat :)
Replythanks ^_^
ReplyConversionConversion EmoticonEmoticon