How do I join 2 vectors in 1 vector? Without repeating the numbers?
Question: Make a program that reads two vectors of 10 elements. Create a vector that is the union between the 2 previous vectors, that is, that contains the numbers of the two vectors. It should not contain repeated numbers.
@edit: I saw some examples on the internet and I came to this but it's pretty wrong ;-)
#include <stdio.h>
int main (){
int vetA[2], vetB[2], vetC[4], i,l,j;
printf ("Informe 10 valores para o VETOR A:\n");
for (i=0; i<2; i++){
scanf ("%d", &vetA);
}
printf ("Informe 10 valores para o VETOR B:\n");
for (i=0; i<2; i++){
scanf ("%d", &vetB);
}
printf ("\nA uniao e: ");
for (i=0; i<2; i++){
if ((vetC[0] != vetA[i]) && (vetC[1] != vetA[i]) && (vetC[2] != vetA[i]))
printf ("%d ", vetA[i]);
}
for (i=0; i<l; i++){
printf ("%d ",vetC);
}
for (j=0; j<2; j++){
if ((vetC[0] != vetB[i]) && (vetC[1] != vetB[i]) && (vetC[2] != vetB[i]))
printf ("%d ", vetB[i]);
}
}