标题:[求助]讲解运行程序结果
只看楼主
yanyupeng
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-9-7
 问题点数:0 回复次数:0 
[求助]讲解运行程序结果
public class Class1
{
Entry top;
public void Push(object data)
{
top=new Entry(top,data);
}
public object Pop()
{
if(top==null)throw new InvalidOperationException();
object result=top.data;
top=top.next;
return result;
}
class Entry
{
public Entry next;
public object data;
public Entry(Entry next,object data)
{
this.next=next;
this.data=data;
}
}

class Program
{
static void Main(string[] args)
{
Class1 s=new Class1();
s.Push(1);
s.Push(10);
s.Push(100);
s.Push(1000);
s.Pop();
s.Pop();
Console.WriteLine(s.Pop());
}
}
}
代码如上,请问为什么输出结果为10。还有第2个s.Pop()为什么返回100
搜索更多相关主题的帖子: 结果 讲解 运行 
2006-09-07 18:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-88685-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.027293 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved