using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _622
{
class QueueTest
{
int [] array;
int length=0;
public QueueTest(int num)
{
array=new int[num];
}
public int length;
{
get
{
return this.length;
}
}
public void Push(int num)
{
if(length>0)
{
for(int i=length-1;i>=0;i--)
{
array[i+1]=array[i];
}
}
array[0]=num;
length++;
}
public int Pop()
{
return array[--length];
}
}
class Program
{
static void Main(string[] args)
{
QueueTest queue=new QueueTest(100);
queue.Push(1);
queue.Push(2);
queue.Push(3);
queue.Push(4);
while(queue.Length>0)
{
Console.Write(queue.Pop()+"\t");
}
Console.Read();
}
}
}
居然有七个,看了半天,还是没该对,希望高手帮忙~
class QueueTest
{
int[] array;
int length = 0;
public QueueTest(int num)
{
array = new int[num];
}
public int Length ;
{
get
{
return this.length;
}
}
public void Push(int num)
{
if (length > 0)
{
for (int i = length - 1; i >= 0; i--)
{
array[i + 1] = array[i];
}
}
array[0] = num;
length++;
}
public int Pop()
{
return array[--length];
}
}
class Program
{
static void Main(string[] args)
{
QueueTest queue = new QueueTest(100);
queue.Push(1);
queue.Push(2);
queue.Push(3);
queue.Push(4);
while (queue.Length > 0)
{
Console.Write(queue.Pop() + "\t");
}
Console.Read();
}
}