Tuesday, August 27, 2013

Convert two vectors of int with the same length into one vector of pairs of int in C++

Convert two vectors of int with the same length into one vector of pairs
of int in C++

In C++, if I have two vectors of int A = [1, 2, 3 ,4] and B = [1, 2, 3,
4], how can I merge them into one vector of pairs as [(1,1), (2,2), (3,3),
(4, 4)]? Of course I can do that with a loop. But can we do that using
suitable STL functions and iterators?
Thanks!

No comments:

Post a Comment