0

I have two vectors:

vector<double>vec1={1, 2, 3, 4, 5}
vector<double>vec2={6, 7, 8, 9, 10}

and I want to generate all possible pairs like:

{1,6}, {1,7}, {1,8}, {1,9}, {1, 10}, {2,6}, {2, 7}...
Jarod42
  • 203,559
  • 14
  • 181
  • 302
hmmmmmm
  • 321
  • 3
  • 10

1 Answers1

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] << "} ";

}
  • 5
    This is wrong. You're printing the indices of the loop, not the values in the `vector`s. – Mike Borkland Sep 23 '18 at 12:44
  • @MikeBorkland my BAD , edited and fixed . But u could've edited it too –  Sep 23 '18 at 15:21
  • Poor values. OP had: vectorvec1={1, 2, 3, 4, 5} vectorvec2={6, 7, 8, 9, 10} which makes it more distinctive. "noone"'s example cannot tell the difference between 1,1 and 1,1 ... –  Sep 23 '18 at 15:35