这是我的尝试
using namespace std;
int main()
{
mt19937 mt(time(0));
cout << mt() << endl;
cout << "----" << endl;
std::ofstream ofs;
ofs.open("/path/save", ios_base::app | ifstream::binary);
ofs << mt;
ofs.close();
cout << mt() << endl;
cout << "----" << endl;
std::ifstream ifs;
ifs.open("/path/save", ios::in | ifstream::binary);
ifs >> mt;
ifs.close();
cout << mt() << endl;
return 0;
}以下是可能的输出
1442642936
----
1503923883
----
3268552048我原以为最后两个数字是一样的。显然,我无法写入和/或读取我的mt19937。你能帮助修复这段代码吗?
https://stackoverflow.com/questions/47582071
复制相似问题