队列和栈
2013-10-24 22:29
387 查看
//队列:先进先出
Queue<int> q = new Queue<int>();
//q.Enqueue();//入队
//q.Dequeue();//出队
q.Enqueue(5);
q.Enqueue(7);
q.Enqueue(2);
while (q.Count>0)
{
int i = q.Dequeue();
Console.WriteLine(i);
}
Console.ReadKey();
//栈:先入后出
Stack<string> s = new Stack<string>();
//s.Push();//压栈
//s.Pop();//出栈
s.Push("A");
s.Push("e");
s.Push("我");
while (s.Count>0)
{
string i = s.Pop();
Console.WriteLine(i);
}
Console.ReadKey();
Queue<int> q = new Queue<int>();
//q.Enqueue();//入队
//q.Dequeue();//出队
q.Enqueue(5);
q.Enqueue(7);
q.Enqueue(2);
while (q.Count>0)
{
int i = q.Dequeue();
Console.WriteLine(i);
}
Console.ReadKey();
//栈:先入后出
Stack<string> s = new Stack<string>();
//s.Push();//压栈
//s.Pop();//出栈
s.Push("A");
s.Push("e");
s.Push("我");
while (s.Count>0)
{
string i = s.Pop();
Console.WriteLine(i);
}
Console.ReadKey();
相关文章推荐
- POJ 1269 Intersecting Lines 直线交
- 多重panel的边框效果
- java类库的阅读笔记_jdk1.7.0_40_java.io.Serializable
- Delphi stdCall意义
- Powershell 开启远程桌面
- Linux常用命令及vim的使用、vim常用插件(推荐)
- Log4Net整理
- xcode4.4+ APP 打包以及提交apple审核详细流程(新版本更新提交审核)
- 黑马程序员-关于三种继承方式
- 黑马程序员--异常与异常的处理
- 移动无线上网卡,PPP连接协议终止,是什么东东?
- 设计一个追踪类
- 黑马程序员--字符串String总结
- 滑动盒子/弹性盒子
- POJ 3304 Segments 线段交
- Windows 8.1中WinRT的变化(二)——新增功能
- Leap::Frame Class Reference 帧类参考
- 黑马程序员--对于面象对象的总结
- SQL优化
- Difference Between Microprocessor and Microcontroller