缓冲区丢了几个
运行下面这段程序(缓冲区最多装 2 个):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<int> buf;
int dropped = 0;
for (int i = 0; i < 5; i++) {
if (buf.size() == 2) dropped++;
else buf.push_back(i);
}
cout << dropped << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论