tugas kul S.data ANTRIAN

#include <cstdlib>
#include <iostream>
//#include “stdio.h”
//#include expects “FILENAME”
using namespace std;

int main()
{ int queue[8];
int depan = -2;
int belakang = -2;
int pilihan, data, i;

do{
cout<<”MENU\n”;
cout<<”1. ENQUEUE\n2. DEQUEUE\n3. VIEW\n4. EXIT\n”;
cout<<”Pilihan = “; scanf(“%d”, &pilihan);
switch (pilihan)
{
case 1: //enqueue
//apakah queue belum penuh?
if (belakang < 4 )
{ cout<<”Data Masuk = “; scanf(“%d”, &data);
queue[belakang+1] = data;
belakang++;
if (belakang == 0)
depan = 0;
}
else
cout<<”Queue penuh!\n”;

break;
case 2: //dequeue
//apakah queue belum kosong?
if (depan <= belakang)
{ cout<<”Data keluar = %d\n”, queue[depan];
depan++;
}
else
cout<<”Queue kosong!\n”;
break;
case 3:
for(i=depan; i<=belakang; i++)
cout<<”%d “, queue[i];
cout<<”\n”;
break;
}
}while (pilihan != 4);
system(“PAUSE”);
return EXIT_SUCCESS;
}