namespace Stack
{
using System;
class Stack
{
private Node first=null;
private int count=0;
public bool Empty
{
get
{
return(first=null);
}
}
public int Count
{
get
{
return count;
}
}
public object Pop()
{
if(first==null)
{
throw new InvalidoperationException("cant pop from an empty stack");
}
else
{
object temp=first.value;
first=first.Next;
count--;
return temp;
}
}
public object Push(object o)
{
first=new Node(o,first);
count++;
}
class Node
{
public Node next;
public object value;
public Node(object value):this(value,null) {}
public Node(object value,Node next)
{
Next=next;
Value=value;
}
}
}
class stackAPP
{
static void Main()
{
Stack s=new Stack();
if(s.Empty)
{
Console.WriteLine("堆栈为空");
}
else
{
Console.WriteLine("堆栈非空");
}
for(int i=0;i<5;i++)
{
s.Psuh(i);
Console.WriteLine("往堆栈里面压入了{0}",s.Count);
}
for(i=0;i<5;i++)
{
Console.WriteLine("往堆栈里面压入了{0}个元素,还剩下{1}个元素",(int)s.pop+1,s.Count);
s=null;
}
}
}
}
怎么说未定义程序的入口什么的?
不是定义了吗?
帮我看看啊