Question: Read two vectors: R of 5 elements and S of 10 elements. generate a 15-element vector X whose first 5 positions contain the elements of R and the last 10 positions, the elements of S. Write the vector X.
First put the values of the vector r within the vector x, but in no way were I able to put the values of the vector s in x, so that it was 0 to 4.
The values of the vector r (I got), but from 5 to 14 I could not get by the ones of the s.
Attempt:
int r[]=new int[5];
int s[]=new int[10];
int x[]=new int[15];
int a1=s.length-1,b=x.length-1;
for (int i = 0; i < r.length; i++) {
System.out.println("Digite valores para o vetor R :");
r[i]=dado.nextInt();
}for (int i = 0; i < s.length; i++) {
System.out.println("Digite valores para o vetor S :");
s[i]=dado.nextInt();
}for (int i = 0; i < r.length; i++) {
x[i]=r[i];
}for (int i =x.length-1; i >=0; i++) {
x[b]=s[a1];
b--;
a1--;
}
for (int j = 0; j < x.length; j++) {
System.out.println("Vetor X indice "+j+" : "+x[j]);
}