换成 vector 当底层
运行下面这段程序:
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
stack<int, vector<int>> s;
s.push(5);
s.push(7);
s.pop();
s.pop();
cout << boolalpha << s.empty() << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论