convert set to vector c++
#include <set>
#include <vector>
std::vector<int> some_vector(some_set.begin(), some_set.end());
convert set to vector c++
#include <set>
#include <vector>
std::vector<int> some_vector(some_set.begin(), some_set.end());
vector assign
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int arr[] = {1, 2, 3, 4, 7};
vector<int> v1;
vector<int> v2;
v1.assign(arr, arr+5);
v2.assign(arr, arr+2);
//printing values of v1
cout << "elements of v1" << endl;
for(int i = 0; i < v1.size(); i++)
{
cout << v1[i] << endl;
}
//printing values of v2
cout << "elements of v2" << endl;
for(int i = 0; i < v2.size(); i++)
{
cout << v2[i] << endl;
}
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us