扫完之后栈里剩几个
运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<char> st;
for (char ch : string("(()")) {
if (ch == '(') st.push_back(ch);
else st.pop_back();
}
cout << st.size() << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论