#include <iostream>
using namespace std;
#define N 11
int queuedata[N];
int front = 0;
int rear = 0;
int add(int data)
{
if (rear < N - 1)
{
rear++;
queuedata[rear] = data;
if (!front)
return -1;
return 1;
}
return -1;
}
int get()
{
int temp;
if (front)
{
temp = queuedata[front];
if (front > rear)
{
front = 0;
rear = 0;
return -1;
}
else
front++;
}
else
return -1;
return temp;
}
void show()
{
for (int i = front+1; i < rear + 1; i++)
{
cout << queuedata[i] << " ";
}
cout << endl;
}
int main(int argc, char** argv)
{
add(5);
add(8);
get();
show();
return 0;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น