我有两个向量:
vector<double>vec1={1, 2, 3, 4, 5}
vector<double>vec2={6, 7, 8, 9, 10}
,我想生成所有可能的对,例如:
{1,6}, {1,7}, {1,8}, {1,9}, {1, 10}, {2,6}, {2, 7}...
答案 0 :(得分:0)
#include <vector>
#include <iostream>
int main()
{
std::vector<int> a = {1,2,3,4,5};
std::vector<int> b = {1,2,3,4,5};
for(int i =0;i<a.size() ;i++)
for(int j =0;j<a.size() ;j++)
std::cout << "{"<< a[i] << "," << b[j] << "} ";
}