std::vector<int> first;
std::vector<int> second;
first.insert(first.end(), second.begin(), second.end());
#include <vector> // vector
#include <iostream> // output
using namespace std;
int main()
{
// two vectors to concatenate
vector<int> A = {1,3,5,7};
vector<int> B = {2,4,6,8};
// vector that will hold the combined values of A and B
std::vector<int> AB = A;
AB.insert(AB.end(), B.begin(), B.end());
// output
for (auto i : AB) {
cout << i << ' ';
}
}
vector<int> a, b;
//fill with data
b.insert(b.end(), a.begin(), a.end());
std::vector<int> AB = A;
AB.insert(AB.end(), B.begin(), B.end());
Code Example |
---|
Cpp :: how to write hello world c++ |
Cpp :: if statement in c++ |
Cpp :: deletion in bst |
Cpp :: for statement in c++ |
Cpp :: transform cpp |
Cpp :: stream in c++ |
Cpp :: Fibonacci Series Program. in c++ |
Cpp :: c vs c++ vs c# |
Cpp :: can derived class access private members |
Cpp :: hello world program in c ++ using standard namespace |
Cpp :: freeing array in c++ |
Cpp :: c++ generate random number upper and lower bound |
C :: C bold output |
C :: c distance between 2 points |
C :: dynamic 2d arr in c |
C :: como programar a area de um triangulo em c |
C :: how to print boolean in c |
C :: close file in c |
C :: malloc int array c |
C :: how to find sum of two nums |
C :: pass the pointer to the function |
C :: c fractional sleep |
C :: check prime number or not c |
C :: how to pass an array of structs as an argument in c |
C :: c strcat |
C :: array reference argument |
C :: celsius to fahrenheit formula |
C :: print variable adress c |
C :: typedef vs #define |
C :: Bitwise Operators in C language |