Arreglos
ARREGLOS
DEFINICIN:
PSEUDOCODIGO LENGUAJE C
Entero a[100], x[50] Int a[100], x[50];
PSEUDOCODIGO LENGUAJE C
Tipo_dato_ident_arreglo[tam_arreglo] Tipo_dato_ident_arreglo[tam_arreglo];
Dnde:
Posicin de memoria 1000 1001 1002 1003 1004 1005 1006 1007
Lista 0 1 2 3
PSEUDOCODIGO LENGUAJE C
Real x[8] Float x[8];
ELEMENTOS
PSEUDOCODIGO LENGUAJE C
a <- x[0] + x[1] + x[2] a = x[0] + x[1] + x[2]
Imprimir a printf(%f,a)
Sintaxis:
PSEUDOCODIGO LENGUAJE C
Tipo_dato identif[tam_arreglo]<-{valores} Tipo_dato identif[tam_arreglo] =
Entero lista[5] <- [10, 17, 8, 4, 9] {valores}
Int lista [5] = {10, 17, 8, 4, 9}
PSEUDOCODIGO LENGUAJE C
Tipo_dato ident_arr[pos]<-valor Tipo_dato ident_arr[pos] = valor;
Entero b[3] <- 18 Int b[3] = 18;
ARREGLOS DE CARACTERES
PSEUDOCODIGO LENGUAJE C
caracter cad[ ]<-Lenguaje Char cad[ ]=Lenguaje;
PSEUDOCODIGO LENGUAJE C
Tipo_dato ident_arr[tam_fila] [tam_col] Tipo_dato ident_arr [tam_fila] [tam_col];
Entero b[3] [4] Int b [3][4];
Dnde:
Sintaxis:
PSEUDOCODIGO LENGUAJE C
t_dato identif[fil] [col] <- {valores} T_dato identif[fil] [col={valores};
Entero a[3][3]<-[1, 2, 3, 4, 5, 6, 7, 8, 9} Int a [3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
LECTURA E IMPRESIN DE UNOS ARREGLOS BIDIMENSIONALES
PSEUDOCODIGO LENGUAJE C
Desde( i<-0, i<3, <-i+1) for( i<-0, i<3, <-i+1)
Desde( j<-0, j<4, <-j+1) for( j<-0, j<4, <-j+1)
Leer mat[i][j] scanf(%d, &mat[i][j]);
PSEUDOCODIGO LENGUAJE C
tipo_dato ident_arr[fil] [col] <- valores tipo_dato ident_arr[fil] [col=valores;
Entero b[3][5]<- 18 Int a [3][5] = 18;
Note que el arreglo x slo tiene un ndice i, esto quiere decir que se est
almacenando en uno de los 50 posibles lugares y en los 20 posibles sitios
que tiene para cada carcter.