STL 栈笔记
本文最后更新于 196 天前,其中的信息可能已经有所发展或是发生改变。
操作功能返回值复杂度
push()入栈O(1)
pop()出栈O(1)
top()取栈顶元素元素值O(1)
empty()判断是否为空boolO(1)
size()获取栈大小整数O(1)
swap()交换两个栈O(1)
输入样例:
olleh !dlrow
输出样例:
hello world!
#include<bits/stdc++.h>
using namespace std;
const int N = 1000010;
typedef long long LL;
typedef list<int>::iterator Iter;
list<int> L;
deque<int> dq;
queue<int> q;
stack<int> s;
vector<LL> a(N + 1, 0);
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    stack<char> ss;
    while (1){
        char ch = getchar();
        if (ch == ' ' || ch == '\n' || ch == EOF) {
            while (!ss.empty()) cout << ss.top(), ss.pop();
            if (ch == '\n' || ch == EOF) break;
            else cout << " ";
        }
        else ss.push(ch);
    }
    return 0;
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇