Write your question here.
if i have to vectors like {3, 2, 4, 5, 1} and {1, 3, 2, 4, 5} and i need to generate new vector take range of one vector and the rest from the another one like ( if the range of first vector 2, 4, 5 and the rest from the another one ,so the final vector is {1, 2, 4, 5, 5})
but i need to prevent duplication of elements within the new vector and replace the duplicated element out of range from first vector {1, 2, 4, 5, 5} by the rest from 1 to 5 like {1, 2, 4, 5,3} . and this is my code but it failed.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
int random(int b) { return std:: rand()%b;};
int main ()
{
std :: cout <<"---------------------------------------------------------------------------"<<"\n";
std:: srand(unsigned (std:: time(0)));
int position_1=0 , position_2 =0, x = 0, y = 0;
do {
x= (rand()%4+1);
y = (rand()%4 +1);
// std :: cout <<x <<"\t"<<y<<"\n";
I'm not quite sure, what the formal description of the problem is.
There are two vectors, V1 and V2. Can they be of different length?
The result vector V3 (with possible duplicates) seems to be: V3 = V2[0..x[ + V1[x..y[ + V2[y..end[
If V3[0..x[ contains values that also occur in V3[x..y[, then they are replaced with something?
If V3[y..end[ contains values that also occur in V3[0..y[, then they are replaced with something?