⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ministack.cpp

📁 数据结构大作业:miniStack类的设计
💻 CPP
字号:
// miniStack.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "l_stack.h"


/*
filename: stack_test.cpp
usage: 测试l_stack.h的实现 
*/

#include <iostream>
#include "l_stack.h"
using namespace std;

int main()
{
    miniStack<int> st;
    
    st.push(1);
    st.push(2);
    st.push(3);
    
    cout << st.top() << ' ';
    st.pop();
    
    cout << st.top() << ' ';
    st.pop();
    
    //modify top elements
    st.top() = 4;
    
    //push two new elements
    st.push(5);
    st.push(6);
    
    //pop one elements without processing it
    st.pop();
    
    //pop and print remaining elements
    while (!st.empty()) {
      cout << st.top() << ' ';
      st.pop();
    }
    cout << endl;
}
/*
程序输出如下:
3 2 5 4 
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -