using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Queue
{
private int font = 0;
private int rear = 0;
private int size = 0;
int[] queue = new int[100];
public int isPan()
{
if (queue.Length == 100)
{
return 0;
}
else
{
return 1;
}
}
public int getSize()
{
size = queue.Length;
return size;
}
public void RuDui(int i)
{
if (isPan() == 0)
{
Console.WriteLine("抱歉队列已满,无法入队!");
}
else
{
queue[rear] = i;
size++;
rear++;
}
}
public void ChuDui()
{
Console.WriteLine(queue[font] + "出队");
size--;
font++;
}
}
}
========================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class ClassMain
{
static void Main()
{
Queue q = new Queue();
Console.WriteLine("队列中总共有:" + q.getSize() + "个元素");
q.RuDui(5);
q.ChuDui();
Console.Read();
}
}
}