-2
How do I join 2 vectors into 1 single 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 two previous vectors, that is, that contains the numbers of the two vectors. It should not contain repeated numbers.
@Dit: I saw some examples on the Internet and I came to that but to ta well 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]);
}
}
thank you :D vlw man
– Gustavo Carvalho
This algorithm works well sss
vetA
contain no repetitions.vetB
can be a hassle-free bag that this algorithm keeps working.– Jefferson Quesado