#include<iostream>
#include<ctime>
using namespace std;
struct node
{
int number;
node *next;
};
struct quene
{
int count;
node *front;
node *end;
};
void inquene(quene *s, int n)
{
if (s->count > SIZE_MAX)
exit(1);
node *t = new node;
t->number = n;
if (s->count == 0)
{
s->front = t;
s->end = t;
}
else
{
t->next = s->end->next;
s->end->next = t;
s->end = t;
}
s->count++;
}
int dequene(quene *s)
{
if (s->count > 0)
{
int t;
t = s->front->number;
node *n = s->front;
s->front = s->front->next;
delete n;
s->count--;
return t;
}
else return -1;
}
void createquene(quene *s, int n)
{
srand(time(0));
for (int i = 1; i <= n; i++)
{
inquene(s, rand() % 100 + 1);
//cout << s->end->number << endl;
}
}
void main()
{
quene *s = new quene;
s->count = 0;
createquene(s, 10);
for (int i = 1; i <= 10; i++)
cout << dequene(s) << endl;
}