1e7 个 bool 是多少 MB
运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long bytes = (long long)sizeof(bool) * 10000000;
cout << bytes / 1000000 << "MB" << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论