このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Putting it together
- A real algorithm joins the pieces: arrays, loops and selection.
- The exam's standard methods are totalling, counting, linear search, and finding the maximum or minimum.
![Values[1] to Values[5] hold 10 to 50; Total grows 10, 30, 60, 100, 150](/static/code/igcse-pseudocode/running-total.png)
English
DECLARE Values : ARRAY[1:5] OF INTEGER
DECLARE I, Total : INTEGER
FOR I ← 1 TO 5
Values[I] ← I * 10
NEXT I
Total ← 0
FOR I ← 1 TO 5
Total ← Total + Values[I]
NEXT I
OUTPUT Total
探索
配列の総和
総和 — 0から始め、ループが访问するたびに配列の各要素を加える。
English
Searching and counting
- Linear search: check each item, and set a flag if you find the target.
- Counting: add 1 to a counter each time a rule is true.
English
DECLARE Values : ARRAY[1:5] OF INTEGER
DECLARE I, Target : INTEGER
DECLARE Found : BOOLEAN
FOR I ← 1 TO 5
Values[I] ← I * 10
NEXT I
Target ← 30
Found ← FALSE
FOR I ← 1 TO 5
IF Values[I] = Target
THEN
Found ← TRUE
ENDIF
NEXT I
OUTPUT Found
English
Common mistakes
- Plan the structure before you write the pseudocode.
- Match the exam's keywords and layout exactly.
English
Now you try
- Each task uses an array that is filled for you — write the algorithm.
- Press Check answer to test it.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
配列Values はすでに埋められています。5 の値をすべて合計して、Total = と合計値を出力してください(合計値は25 です)。
実行ボタンをクリックして出力を確認してください。
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
配列 Values にはすでに値が入っています。線形探索を使って、9 が配列に含まれている場合はFound にTRUE を設定し、最後にFound を出力してください。
実行ボタンをクリックして出力を確認してください。
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
配列Values はすでに埋められています。4 より大きい値がいくつあるか数えて、そのカウントを出力してください(値は3 です)。
実行ボタンをクリックして出力を確認してください。