现在我想计算 80 里面取 20 个数的所有组合可能, 这个数据量比较大, 计算比较耗时, 享用多线程计算应该会快, 但是不知到多线程怎么写这个程序
https://stackoverflow.com/questions/9430568/generating-combinations-in-c
计算方法参考的这个链接
#include <iostream>
#include <algorithm>
#include <vector>
int main() {
int n, r;
std::cin >> n;
std::cin >> r;
std::vector<bool> v(n);
std::fill(v.end() - r, v.end(), true);
do {
for (int i = 0; i < n; ++i) {
if (v[i]) {
std::cout << (i + 1) << " ";
}
}
std::cout << "\n";
} while (std::next_permutation(v.begin(), v.end()));
return 0;
}