본문 바로가기
Data structure

Arrays

by Doromi 2023. 10. 3.
728x90
반응형

An array is a sequential list of values. You can use arrays to store and access multiple values of the same data type under one identifier. Arrays makes it easier to perform operations on an entire dataset. They’re also great for retrieving data.

There are one-dimensional arrays and multi-dimensional arrays. The values stored in an array are called elements. Elements are stored in consecutive blocks of memory called indexes. The size of an array is determined by the number of elements it contains. Pictured is a one-dimensional array with a size of six.

 

배열은 값의 연속적인 목록입니다. 배열을 사용하여 동일한 데이터 유형의 여러 값을 하나의 식별자 아래에 저장하고 액세스할 수 있습니다. 배열은 전체 데이터 집합에 대한 작업을 수행하기 쉽게 만들어 줍니다. 또한 데이터를 검색하는 데도 훌륭합니다.

일차원 배열과 다차원 배열이 있습니다. 배열에 저장된 값들을 요소라고 합니다. 요소는 인덱스라고 불리는 연속된 메모리 블록에 저장됩니다. 배열의 크기는 포함된 요소의 수에 의해 결정됩니다. 아래 그림은 크기가 6인 일차원 배열을 나타냅니다.

The general syntax for initializing a one-dimensional array is:

ArrayName [ArrayIndex] = value;

In this code, we initialize an array named Example that stores 200 at index 0 and 201 at index

일차원 배열을 초기화하는 일반적인 구문은 다음과 같습니다:

ArrayName[ArrayIndex] = value;

이 코드에서 우리는 Example이라는 배열을 초기화하고 인덱스 0에 200을 저장하고 인덱스 1에 201을 저장합니다.

#include <iostream>

using namespace std;

int main() {

  int Example[2];

  Example[0] = 200;
  Example[1] = 201;

}
728x90
반응형