目錄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; }