forked from landbroken/BasicKnowledge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_main.cpp
More file actions
43 lines (37 loc) · 766 Bytes
/
stack_main.cpp
File metadata and controls
43 lines (37 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Stack.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include"StackDemo.h"
using namespace std;
int main()
{
ArrStack arrS(5);
//插入
cout << "arrS.Push(a):" << endl;
arrS.Push(1);
cout << " " << arrS.GetTop() << " ";
arrS.Push(2);
cout << " " << arrS.GetTop() << " ";
arrS.Push(3);
cout << " " << arrS.GetTop() << " " << endl;
//删除
cout << "arrS.Pop():" << endl;
arrS.Pop();
cout << " " << arrS.GetTop() << " ";
arrS.Pop();
cout << " " << arrS.GetTop() << " ";
try
{
arrS.Pop();
cout << " " << arrS.GetTop() << " " << endl;
}
catch (const std::exception& e)
{
cout << "Error: " << e.what() << endl;
}
//空栈
cout << "arrS.IsEmpty(): " << arrS.IsEmpty() << " ";
system("pause");
return 0;
}