Considere o programa em Java abaixo.
import java.util.Random;
public class Main {
public static void main(String[] args) {
int[] v;
int i, max=10;
Random gerador = new Random();
I
System.out.println("Vetor randômico:\n");
i=0;
while (i < max) {
II
System.out.println("v["+i+"]= " + v[i]);
++i;
}
}
}
Em condições ideais, para que sejam gerados números randômicos entre 1 e 100 e estes sejam inseridos nas max posições do vetor v, as lacunas I e II devem ser preenchidas, correta e respectivamente, por:
import java.util.Random;
public class Main {
public static void main(String[] args) {
int[] v;
int i, max=10;
Random gerador = new Random();
I
System.out.println("Vetor randômico:\n");
i=0;
while (i < max) {
II
System.out.println("v["+i+"]= " + v[i]);
++i;
}
}
}
Em condições ideais, para que sejam gerados números randômicos entre 1 e 100 e estes sejam inseridos nas max posições do vetor v, as lacunas I e II devem ser preenchidas, correta e respectivamente, por:
- A)int v = new v[max]; e v[i]= 1+ gerador.rand(100);
- B)v = new int[max]; e v[i]= ++gerador.nextRand(100);
- C)int v[] = new v[max]; e v[i]= gerador.rand(100);
- D)v[] = new int[max]; e v[i]= gerador.nextInt(100);
- E)v = new int[max]; e v[i]= 1+ gerador.nextInt(100);