본 문서는 인프런의 [하루 10분|C++] 누구나 쉽게 배우는 C++ 프로그래밍 입문 강의를 공부하며 작성한 개인 노트입니다.
for (int i = 0; i < 5; i++) {
//code
}
int i = 0
를 for loop 전에 선언해도 됨++
, --
a++
> 변수를 판단한 후 값 증가++a
> 변수 값 증가 후 판단 int i = 0;
while (i <3) {
//code
i++;
}
int j = 0;
do {
// code
j++;
} while (j < 3);
do
코드 수행 후 while
조건 확인int a[5] = { 1, 3, 5, 7, 9 };
for (int i : a) {
cout << i;
}
a
의 크기보다 적게 원소를 정의하면 배열 기반 반복문 사용시 정의되지 않은 원소는 0으로 사용됨int temp[4][5] =
{
{1, 2, 3, 4, 5},
{11, 22, 33, 44, 55}
}
for (int row = 0; row < 4; row++) {
for (int col = 0; col <5; col++) {
cout << temp[row][col] << endl;
}
}