Arrays and file handling · Arreglos y manejo de archivos
| English | Español |
|---|---|
| array/əˈreɪ/ | array |
| index/ˈɪndeks/ | índice |
| nested/ˈnestɪd/ | anidado |
| file handling/faɪl ˈhændlɪŋ/ | gestión de archivos |
Arrays 数组 and files
- An array stores many values of the same type in one variable.
- A file lets a program keep data after it stops.
- Loops are the natural way to work through both.
Arrays 数组 y archivos
- Una array (matriz) almacena muchos valores del mismo tipo en una sola variable.
- Un archivo permite a un programa conservar datos después de que se detiene.
- Los bucles son la forma natural de recorrer ambos.
One-dimensional arrays
- A 1D array is like a single list; each value is found by an index 索引 (a position number).
- A loop fills or reads the whole array.
A 1D array holds many values in one variable; each is found by its index.
Arrays unidimensionales
- Una array 1D es como una lista simple; cada valor se encuentra mediante un índice (un número de posición).
DECLARE Scores : ARRAY[1:5] OF INTEGER
Scores[1] ← 90
FOR I ← 1 TO 5
INPUT Scores[I]
NEXT I
- Un bucle rellena o lee toda la array.

Una array 1D contiene muchos valores en una variable; cada uno se encuentra por su índice.
An array is: · Un array es:
An array stores many same-type values under one name; each is accessed by its index. · Un array almacena muchos valores del mismo tipo bajo un solo nombre; cada uno se accede mediante su índice.
Two-dimensional arrays
- A 2D array is like a table with rows and columns, using two indexes
[row, column].
- You read a 2D array with a loop inside a loop (nested 嵌套 iteration).
A 2D array is a table; each value is found by two indexes, (row, column).
Arrays bidimensionales
- Una array 2D es como una tabla con filas y columnas, utilizando dos índices
[row, column].
DECLARE Grid : ARRAY[1:3, 1:3] OF INTEGER
Grid[2, 3] ← 8 // row 2, column 3
- Se lee una array 2D con un bucle dentro de otro bucle (iteración anidada).

Una array 2D es una tabla; cada valor se encuentra mediante dos índices, (fila, columna).
Index a 2-D array: Grid[Row, Col] · Indexar un array 2-D: Grid[Row, Col]
A 2-D array is a grid of values. Grid[Row, Col] reaches exactly one cell — the row first, then the column. Cambridge counts both from 1. · Un array 2-D es una cuadrícula de valores. Grid[Row, Col] accede exactamente a una celda — primero la fila, luego la columna. Cambridge cuenta ambos desde 1.
In grid[2, 3], which cell is accessed? · En grid[2, 3], ¿qué celda se accede?
The first index is the row, the second the column — row 2, column 3. · El primer índice es la fila, el segundo la columna — fila 2, columna 3.
Match each idea to what it means. · Empareja cada concepto con lo que significa.
Arrays hold many values by index; a 2-D array is a grid; nested loops walk it; files are opened, used and closed. · Los arrays almacenan muchos valores por índice; un array 2-D es una cuadrícula; los bucles anidados lo recorren; los archivos se abren, usan y cierran.
File handling 文件处理
- A program can store data in a file so it survives after the program stops.
- Open the file, use it, then close it:
- Always close a file when finished (use
FOR READto read it back).
A counter counts up by 1; a total builds a running sum
Manejo de archivos
- Un programa puede almacenar datos en un archivo para que sobrevivan después de que el programa se detenga.
- Abrir el archivo, usarlo y luego cerrarlo:
OPENFILE "data.txt" FOR WRITE
WRITEFILE "data.txt", "Hello"
CLOSEFILE "data.txt"
- Siempre cierra un archivo cuando termines (usa
FOR READpara leerlo de nuevo).

Un contador suma de 1 en 1; un total construye una suma acumulativa
Put the steps of using a file in the correct order. · Coloca los pasos para usar un archivo en el orden correcto.
Always open first, then do the reading/writing, then close to save buffered data and free the file. · Siempre abrir primero, luego realizar la lectura/escritura, y luego cerrar para guardar los datos en buffer y liberar el archivo.
You should always close a file when you have finished using it. · Debes cerrar siempre un archivo cuando hayas terminado de usarlo.
Closing saves any buffered data and frees the file for other programs. · Cerrar guarda cualquier dato en buffer y libera el archivo para otros programas.
You've got it
- a 1D array is a list reached by one index; fill/read it with a loop
- a 2D array is a table reached by
[row, column]; use nested loops - file handling: OPENFILE (READ/WRITE) → READFILE/WRITEFILE → CLOSEFILE
- always close a file when done
Ya lo dominas
- una array 1D es una lista accedida por un solo índice; rellénala/léela con un bucle
- una array 2D es una tabla accedida por
[row, column]; usa bucles anidados - manejo de archivos: OPENFILE (READ/WRITE) → READFILE/WRITEFILE → CLOSEFILE
- siempre cierra un archivo cuando hayas terminado