Tema 8 Arreglos Parte 1
arreglos
Concepto Se identifican por un nombre. Tabla, vector, matriz o array. Conjunto de elementos del mismo tipo. Se identifican por un nombre. Están en una zona de almacenamiento contínuo.
Arreglos unidimensionales 1 2 3 4 5 6 7 8 9 50 18 10 33 59 15 40 arregloPrueba
Definición de Arreglos unidimensionales tipo[] idArreglo= new tipo[dimensión]; Ejemplos: int [] tabla1= new int[10]; float[] ejemplo= new float[5];
Arreglos unidimensionales 1 2 3 4 5 6 7 8 9 tabla1 1 2 3 4 ejemplo
Arreglos unidimensionales Acceso a los elementos: idArreglo[índice] Ejemplos: tabla1[0]= 10; //C# utiliza indexación base-0 ejemplo[3]= ejemplo[1];
Arreglos unidimensionales 1 2 3 4 5 6 7 8 9 10 tabla1[0]=10 1 2 3 4 58 ejemplo[3]=ejemplo[1]
Arreglos unidimensionales Asignar valores iniciales: tipo[] idArreglo= {valor1, valor2,..}; Ejemplos: int [] tabla1= {50,12,45,-4,55}; float[] ejemplo= {12,18,0};
Recorrer los elementos de un arreglo Utilizar una estructura repetitiva. 1 2 3 4 5 6 7 8 9 índice