我正在尝试在使用 system()
调用程序时为 minisat 尝试一些随机参数。我以前从未做过这样的事情,不得不承认我很迷茫。
例如我可以这样做:
system("minisat -luby -rinc=1.5 <dataset here>")
我如何将它随机化为 -luby
或 -no-luby
并将 1.5
值随机化为 -rinc
?
最佳答案
system 只是一个普通的函数,它接收一个 c 风格的字符串作为参数。您可以自己构造字符串。
bool luby = true;
double rinc = 1.5;
system((std::string("minisat -")+(luby?"luby":"no-luby")+" -rinc="+std::to_string(rinc)).c_str());
关于c++ - 使用 System() 的随机参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39302402/