Entradas - Tam do 1 vetor:5/
Elementos do 1 vetor: 1 2 3 4 5 /
Elementos do 2 vetor: 6 7 8 9 10/
Pos a ser inserida: 1
Saida-
6 1 7 8 9 10 /
6 2 1 7 8 9 10 /
6 3 2 1 7 8 9 10 /
6 4 3 2 1 7 8 9 10/
6 5 4 3 2 1 7 8 9 10
NOTE: The size of the second vector should be twice the size of the first vector, but the second vector will be only half its size.
I'm a bit lost, for now this is my code:
#include <iostream>
using namespace std;
int main(){
int tam1, tam2, pos;
cin>>tam1;
int vet1[tam1];
for(int i=0; i<tam1; i++){
cin>>vet1[i];
}
tam2=tam1*2;
int vet2[tam2],vetaux[tam2];
for(int i=0; i<(tam2/2); i++){
cin>>vet2[i];
vetaux[i]=vet2[i];
}
cin>>pos;
for(int i=0; i<tam2; i++){
vet2[pos]=vet1[i];
vet2[pos+1]=vetaux[pos];
cout<<vet2[i]<<" ";
pos++;
}
}