C++ stack 使用

//stack用法示例1
#include 
#include 
#include 
#include 
using namespace std;



int main() {
    int i = 0;
    stack> obi;
    for (int i = 0; i < 10; i++)
    {
        obi.push(i);
    }
    while (obi.size() > 0) {
        int x = obi.top();
        cout << x << " ";
        obi.pop();
    }

    cout << endl << endl;

    stack>obs;
    for (char c = 'A'; c <= 'Z'; c++)
    {
        string s(1, c);
        obs.push(s);
    }
    while (obs.size())
    {
        string str = obs.top();
        cout << str << " ";
        obs.pop();
    }
    cout << endl << endl;
    system("pause");
    return 0;
}
//stack用法示例1
#include 
#include 
#include 
#include 
using namespace std;

int main() {
    int i = 0;
    stack v;
    for (i=0;i<10;++i)
    {
        v.push(i);
        cout << v.top() << "已入栈"<

你可能感兴趣的:(C++ stack 使用)