1-D arrays · 1차원 배열
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
A list of the same type
- An array holds a fixed number of values of one type.
- The guide's lower bound is 1 unless a question says otherwise.
- One index, in square brackets, picks an element.
한국어
동일한 유형의 목록
- 배열은 특정 타입의 고정된 수의 값을 저장합니다.
- 질문에서 다르게 명시하지 않는 한 가이드의 하한은 1입니다.
- 사각 괄호 안의 인덱스 하나를 사용하여 요소를 선택합니다.
English
한국어
DECLARE Score : ARRAY[1:5] OF INTEGER
Score[1] ← 4
Score[2] ← 8
OUTPUT Score[1]
English
A loop visits every cell
- A
FORloop from the lower bound to the upper bound is how you fill or read the array.
한국어
루프가 모든 셀을 방문함
- 하한에서 상한까지
FOR루프를 사용하여 배열을 채우거나 읽습니다.
DECLARE Score : ARRAY[1:3] OF INTEGER
Score[1] ← 4
Score[2] ← 8
Score[3] ← 6
DECLARE Total : INTEGER
Total ← 0
FOR I ← 1 TO 3
Total ← Total + Score[I]
NEXT I
OUTPUT Total
English
Watch out
Score[1]is the first cell when the array was declared[1:5].- The index can be an expression:
Score[I + 1].
한국어
주의사항
Score[1]은 배열이[1:5]으로 선언되었을 때 첫 번째 셀입니다.- 인덱스는 식일 수 있습니다:
Score[I + 1].
English
Common mistakes
- Declare the array before you store into a cell.
- The index must stay inside the declared bounds.
한국어
흔한 실수
- 셀에 값을 저장하기 전에 배열을 선언하십시오.
- 인덱스는 선언된 범위를 벗어나서는 안 됩니다.
English
Now you try
- Store three numbers and total them.
한국어
이제 직접 해보기
- 세 숫자를 저장하고 합계하되세요.
Declare Score as ARRAY[1:3] OF INTEGER. Store 4 in cell 1 and output that cell. · Score을 ARRAY[1:3] OF INTEGER로 선언하십시오. 1번 셀에 4을 저장하고 해당 셀을 출력하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
The array is filled for you. Total the three values and output the total (18). · 배열은 미리 채워져 있습니다. 세 값의 총합을 구하여 총합(18)을 출력하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.