Arrays and file handling
導入済み
13:08
プログラミング
Here is a short program. It reads five test marks and prints the total. The five marks are eight, nine, seven, six and ten, so the total should be forty. Watch…
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| array/əˈreɪ/ | 配列 |
| file/faɪl/ | A named collection of data stored and managed as a unit. |
| variable/ˈveərɪəbl/ | A quantity or named value that can change or take different values. |
| data/ˈdeɪtə/ | Recorded facts, observations or values used for analysis or processing. |
| Loops | The natural way to work through both. |
| One-dimensional arrays | |
| 1D array | |
| index/ˈɪndeks/ | 添字 |
| READ | |
| Two-dimensional arrays | |
| 2D array/ˌtuː ˈdiː əˈreɪ/ | |
| nested/ˈnestɪd/ | 階層構造 |
| iteration/ˌɪtəˈreɪʃn/ | Repeating a sequence of instructions or calculations. |
| file handling/faɪl ˈhændlɪŋ/ | ファイル操作 |
| pseudocode/ˈsuːdəʊkəʊd/ | A language-independent description of an algorithm using structured, programming-like statements. |
| loop variable/luːp ˈveərɪəbl/ | |
| OPENFILE | |
| READFILE | |
| WRITEFILE | |
| CLOSEFILE |
配列とファイル
- 配列 は単一の変数に同じ型の多数の値を格納する。
- ファイル は、プログラム終了後もデータを保持させることができる。
- ループはこれら両方を処理する自然な方法である。
一次元配列
- 1D配列 は単一のリストのようなもので、各値はインデックス(位置番号)で見つかる。
DECLARE Scores : ARRAY[1:5] OF INTEGER
Scores[1] ← 90
FOR I ← 1 TO 5
INPUT Scores[I]
NEXT I
- ループを使って配列全体を埋めたり読み出したりする。

1D配列は単一の変数に多数の値を保持し、各値はインデックスで見つかります。

An array is:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
An array stores many same-type values under one name; each is accessed by its index.
二次元配列
- 2D配列 は行と列を持つ表のようなもので、2つのインデックス
[row, column]を使用する。
DECLARE Grid : ARRAY[1:3, 1:3] OF INTEGER
Grid[2, 3] ← 8 // row 2, column 3
- 2D配列は、ループ内のループ(ネスト反復)を使って読み出す。

2D配列は表であり、各値は2つのインデックス(行, 列)で見つかります。

Index a 2-D array: 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.
In grid[2, 3], which cell is accessed?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
The first index is the row, the second the column — row 2, column 3.
Match each idea to what it means.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Arrays hold many values by index; a 2-D array is a grid; nested loops walk it; files are opened, used and closed.
ファイル操作
- プログラムはデータをファイルに格納することで、プログラム終了後も残せる。
- ファイルを開く、使う、そして閉じる:
OPENFILE "data.txt" FOR WRITE
WRITEFILE "data.txt", "Hello"
CLOSEFILE "data.txt"
- 完了したら必ずファイルを閉じる(
FOR READを使って再度読み出す)。

カウンタは1ずつ増やします;-totalは蓄積和を作ります
Put the steps of using a file in the correct order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Always open first, then do the reading/writing, then close to save buffered data and free the file.
You should always close a file when you have finished using it.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Closing saves any buffered data and frees the file for other programs.
理解できましたか
- 1D配列 は1つのインデックスでアクセスできるリストであり、ループで埋めたり読み出したりする
- 2D配列 は
[row, column]でアクセスできる表であり、ネストループを使用する - ファイル操作: OPENFILE (READ/WRITE) → READFILE/WRITEFILE → CLOSEFILE
- 完了したら必ずファイルを閉じる
Scores 保持する 90 75 60 88 50 with the first index 1. What is Scores[4]?
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Counting from index 1: 90, 75, 60, 88.
Data in an array is lost when the program stops, but data written to a file is kept.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Arrays live in RAM while the program runs; a file is saved to storage.
このカードは新しいため、翻訳ができるまで英語で表示されます。
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
何が問題でしたか?この内容はサイトの運営チームだけが確認します。