#include<stdio.h>
#include<conio.h>
void main ()
{
int cek=0,data[20],x,hapus;
char pil;
do
{
clrscr();
printf("1.tambah antrian:\n");
printf("2.hapus antrian:\n");
printf("3.lihat antrian:\n");
printf("4.keluar:\n");
pil=getch();
if(pil !='1' &&pil!='2'&&pil!='3'&&pil!='4')
printf("\nanda telah mengetikan inputan...\n");
else
{
if(pil=='1')
{
if(cek==20)
printf("\nantrian penuh\n");
else
{
printf("\nmasukan nilai\n"); scanf("%i",&x);
data[cek]=x;
cek++;
}
}
else
{
if(pil=='2')
{
if(cek==0)
printf("\nantrian kosong\n");
else
{
hapus=data[0];
for(int v=0;v<cek;v++)
data[v]=data[v+1];
data[cek-1]=NULL;
cek--;
printf("\ndata dengan nilai=%i terhapus",hapus);
}
getch();
}
else
{
if(pil=='3')
{
if(cek==0)
printf("\nantrian kosong\n");
else
{
printf("\n");
for(int z=0;z<cek;z++)
{
printf(" | ");
printf("%i",data[z]);
printf(" | ");
}
}
getch();
}
}
}
}
}while(pil!='4');
}
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar