Doubt about Index of a vector | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Doubt about Index of a vector

hi people have a doubt how make the attributes the index of a vector ex 0 v[0] or 1 v[1]. this My code: public static void main(String[] args) { Scanner teclado = new Scanner(System.in); System.out.println("Atribuidor de vector com seu proprio Indice "); System.out.println("Introduza o tamanho do Vector: "); int n = teclado.nextInt(); int dim[] = new int[n]; System.out.println("Listagem de numeros no Vetor"); for (int i = 0; i < dim.length; i++) { System.out.printf("numero: %d \n %d v[%d] ",n, i, i); int v = teclado.nextInt(); dim[i] = v; } } }

23rd Nov 2017, 11:28 PM
Xremix27
Xremix27 - avatar
1 Antwort
0
What you have works. If I enter: 5 4 2 5 1 3 I get: n=5 dim[0]=4 dim[1]=2 dim[2]=5 dim[3]=1 dim[4]=3 dim.length=5
24th Nov 2017, 12:14 AM
John Wells
John Wells - avatar