#ifndef QUEUE_H
#define QUEUE_H
const int size = 5;
template<class MyData>
class Queue
{
private:
MyData tata[size];
int bil;
int front;
int rear;
public:
Queue();
void Enqueue(MyData);
void Dequeue();
MyData QueueFront();
MyData QueueRear();
bool Empty();
};
#endif
template<class MyData>
Queue
{
front = -1;
rear = -1;
bil = 0;
}
template <class MyData>
void Queue
{
if (bil < style="color: rgb(255, 0, 0);">\nInsert
rear++;
if (rear == size)
rear = 0;
if (bil == 0)
front = 0;
tata[rear] = value;
bil++;
}
else
cout << "Overflow!!!";
}
template<class MyData>
void Queue
{
if (bil == 0)
cout << "Underflow!!!!";
else
{
cout << "\nDequeue:" <<>if (front == size)
front = 0;
if (bil == 1)
rear = front = -1;
bil--;
}
}
template<class MyData>
bool Queue
{
return (bil == 0);
}
template<class MyData>
MyData Queue
{
if (Empty())
return false;
else
return tata[front];
}
template<class MyData>
MyData Queue
{
if (Empty())
return false;
else
return tata[rear];
}
//Utama.cpp
#include<iostream>
using namespace std;
#include "Queue.h"
void main()
{
Queue<char>MyQ;
char i;
cout << "\nPlease insert a data, 1 to Dequeue data or 0 to stop: ";
cin>>i;
while (i != '0'){
if (i == '1')
MyQ.Dequeue();
else
MyQ.Enqueue(i);
if(!MyQ.Empty())
{
cout << "\nQueue front now is: " <<>\nQueue rear now is: " <<>\nPlease insert a data, 1 to Dequeue data or 0 to stop: ";
cin >> i;
}}
cout <<>
}
Will output this :
Haha..apekah yang sedang saya lakukan? hee;p btw, ini adalah sedikit codding yang dipelajari. Untuk digunakan dalam Queue. Queue digunakan dalam penyimpanan data. Queue adalah First in First Out. huhu..saje je nak post entry pasal codding sebab aku ade labtest esok. argh..ahahah;p
Ganbatte Hayati!!!
Queue by array
Welcome to my blog. Before anything else please follow these rules : no RIPPING, 














My Parents + dakMOK!
Me and My Parents
My Parents
4 Comments:
akak penin!
trus scroll down laju2.. ahha
09 April, 2009
ngahaa...sampai ati kaka. bace la satu2 mesti akan paham punya. kekekke;p
09 April, 2009
Last in Last Out dalam Operating System !!
dat's why la aku tak sambung degree aku dalan Information Technology !!
serik kot betty!!
ckup la diploma aku terseksa jiwa dan ragaaaaaaaaaaa :p
10 April, 2009
Queue adik beradik dengan Stack. aku pun hampir2 konpius dua2 mende ni. nak taknak kene la belajar. kepuasan terasa bila dapat debug n run mende ala ni. hahaha..tapi aku bengang la..nape multimedia kene belajar database jugak ke?? argh..fenin!!!
11 April, 2009
Post a Comment
Subscribe to Post Comments [Atom]
<< Home