题解 | 逆序输出

逆序输出

https://www.nowcoder.com/practice/bb66c27cb7aa48f9ba7d9f88e4068285

#include <iostream>
#include<algorithm>
#include<stack>
using namespace std;

int main() {

    stack<int> s;
    int x;
    for(int i=1;i<=10;i++)
    {
        cin>>x;
        s.push(x);
    }
    while(!s.empty())
    {
        cout<<s.top()<<' ';
        s.pop();
    }
}
// 64 位输出请用 printf("%lld")

一个最为简单的栈的应用,后进先出嘛。

但是,我受不了了我用的insert我真的分不清insert push push_back啊喂!

全部评论
癫狂/
点赞 回复 分享
发布于 03-13 20:35 河南

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务