Professional Documents
Culture Documents
ARREGLOS
ARREGLOS UNIDIMENSIONALES
NDICE DE UN ARREGLO
ELEMENTO DE UN ARREGLO
Tal como a otros tipos de variables, puede darle valores iniciales a los
elementos de un arreglo. Esto se consigue especificando una lista de
valores que tendrn los elementos del arreglo.
Esto significa que mem[0] tendr el valor de 1, y que mem[4] tendr el valor
de 15. Para la inicializacin de arreglos de caracteres existen dos maneras.
Si el arreglo no tiene una cadena terminada en nulo, simplemente
especifique cada carcter usando una lista separada por comas como se
muestra a continuacin:
ARREGLOS TETRADIMENSIONALES
Elemento 0, 0, 0, 0 0, 0, 1, 0 0, 0, 2, 0 0, 0, 3, 0 0, 0, 4,0
Elemento 0, 0, 0, 1 0, 0, 1, 1 0, 0, 2, 1 0, 0, 3, 1 0, 0, 4,1
Elemento 0, 0, 0, 2 0, 0, 1, 2 0, 0, 2, 2 0, 0, 3, 2 0, 0, 4,2
Elemento 0, 0, 0, 3 0, 0, 1, 3 0, 0, 2, 3 0, 0, 3, 3 0, 0, 4,3
Elemento 0, 0, 0, 4 0, 0, 1, 4 0, 0, 2, 4 0, 0, 3, 4 0, 0, 4,4
Elemento 0, 1, 0, 0 0, 1, 1, 0 0, 1, 2, 0 0, 1, 3, 0 0, 1, 4,0
Elemento 0, 1, 0, 1 0, 1, 1, 1 0, 1, 2, 1 0, 1, 3, 1 0, 1, 4,1
Elemento 0, 1, 0, 2 0, 1, 1, 2 0, 1, 2, 2 0, 1, 3, 2 0, 1, 4,2
Elemento 0, 1, 0, 3 0, 1, 1, 3 0, 1, 2, 3 0, 1, 3, 3 0, 1, 4,3
Elemento 0, 1, 0, 4 0, 1, 1, 4 0, 1, 2, 4 0, 1, 3, 4 0, 1, 4,4
Elemento 0, 2, 0, 0 0, 2, 1, 0 0, 2, 2, 0 0, 2, 3, 0 0, 2, 4,0
Elemento 0, 2, 0, 1 0, 2, 1, 1 0, 2, 2, 1 0, 2, 3, 1 0, 2, 4,1
Elemento 0, 2, 0, 2 0, 2, 1, 2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, 0, 2 3, 0, 1, 2 3, 0, 2, 2 3, 0, 3, 2 3, 0, 4,2
Elemento 3, 0, 0, 3 3, 0, 1, 3 3, 0, 2, 3 3, 0, 3, 3 3, 0, 4,3
Elemento 3, 0, 0, 4 3, 0, 1, 4 3, 0, 2, 4 3, 0, 3, 4 3, 0, 4,4
Elemento 3, 1, 0, 0 3, 1, 1, 0 3, 1, 2, 0 3, 1, 3, 0 3, 1, 4,0
Elemento 3, 1, 0, 1 3, 1, 1, 1 3, 1, 2, 1 3, 1, 3, 1 3, 1, 4,1
Elemento 3, 1, 0, 2 3, 1, 1, 2 3, 1, 2, 2 3, 1, 3, 2 3, 1, 4,2
Elemento 3, 1, 0, 3 3, 1, 1, 3 3, 1, 2, 3 3, 1, 3, 3 3, 1, 4,3
Elemento 3, 1, 0, 4 3, 1, 1, 4 3, 1, 2, 4 3, 1, 3, 4 3, 1, 4,4
Elemento 3, 2, 0, 0 3, 2, 1, 0 3, 2, 2, 0 3, 2, 3, 0 3, 2, 4,0
Elemento 3, 2, 0, 1 3, 2, 1, 1 3, 2, 2, 1 3, 2, 3, 1 3, 2, 4,1
Elemento 3, 2, 0, 2 3, 2, 1, 2 3, 2, 2, 2 3, 2, 3, 2 3, 2, 4,2
Elemento 3, 2, 0, 3 3, 2, 1, 3 3, 2, 2, 3 3, 2, 3, 3 3, 2, 4,3
Elemento 3, 2, 0, 4 3, 2, 1, 4 3, 2, 2, 4 3, 2, 3, 4 3, 2, 4,4
de dato
En donde:
nomVar Es el nombre de la variable.
arreglo.
arreglo.
arreglo.
Ejemplo:
En donde:
Ejemplos:
Elaborar un algoritmo que lea nmeros de tipo entero para un arreglo como
el esquematizado lneas antes, es decir, un arreglo de 4 x 3 x 5 x 5, y los
imprima.
Explicacin:
En el programa netbeans
Algoritmo ARREGLO TETRADIMENSIONAL
Clase ArregloCuatroDim
Mtodo principal ()
a. Declarar
Variables
Nmeros: Arreglo [4] [3] [5] [5]: Entero
ren1, col1, ren2, col2: Entero
b. for ren1=0; ren1<=3; ren1++
1. for col1=0; col1<=2; col1++
a. for ren2=0; ren2<=4; col 2++
1. for col2=0; col2<=4; col2++
a. solicitar
Nmeros [ren1] [col1] [ren2] [col2]
b. leer Nmeros [ren1] [col1] [ren2] [col2]
2. endfor
b. endfor
2. endfor
c. endfor
d. for ren1=0; ren1 <=3; ren1++
1. for col1=0; col1<=2; col1++
a. for ren2=0; ren2<=4; ren2++
1. for col2=0; col2<=4; col2++
a. imprimir
Nmeros [ren1] [col1] [ren2] [col2]
2. endfor
b. endfor
2. endfor
e. endfor
f. Fin Mtodo principal
Fin Clase ArregloCuatroDim
Fin