-1
I have the following code:
import java.util.Scanner;
public class ativ15 {
public static void main (String[] args) {
Scanner sc = new Scanner (System.in);
int i;
int A[] = new int [10];
int B[] = new int [A.length];
System.out.println ("Digite os elementos do vetor: ");
for (i=0; i<10; i++){
A[i] = sc.nextInt();
}
GeraInverso (A, B);
}
static void GeraInverso (int A[], int B[]) {
int i, temp;
for (i=0; i<A.length; i++){
B[i] = A[i];
}
for (i=0; i<10; i++) {
if (i<5) {
temp = B[i];
B[i] = B[10-i-1];
B[10-i-1] = temp;
}
}
}
}
I need the main function to print the value of the vector B (the inverse Generating function reverses the values of the vector A and copies to the vector B). For this what should the Generationinverse function return? How should I proceed?
then how do I print the vector in the main function? because I’ve tried it in some ways and give different errors
– Leko
Do as you did to read it: a loop. And print
B[i]
– Emoon
was missing a } that generated several errors. Thank you!
– Leko
@Leko’s previous answer, which you apparently did not like, shows all that you want to know here, which was not answered and you liked: http://answall.com/a/164296/101
– Maniero