目录ios
重要的数据结构。数据结构
操做:spa
#include <stack> #include <iostream> using namespace std; int main() { stack<int> intStack; // 压 4个元素入栈 intStack.push(16); intStack.push(8); intStack.push(20); intStack.push(3); // 取栈顶元素,并弹栈 cout << "top of intStack:" << intStack.top() << endl; intStack.pop(); cout << "top of intStack:" << intStack.top() << endl; while(!intStack.empty()) { cout << intStack.top() << " "; intStack.pop(); } cout << endl; return 0; }