Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- dynamic
- W3Schools
- python
- 백준
- dfs
- UE5
- Programming
- github
- Material
- Algorithm
- 문제풀이
- C#
- c++
- Unity
- guide
- 재귀
- w3school
- 기초
- 오류
- loop
- Tutorial
- 파이썬
- DP
- 프로그래밍
- 시작해요 언리얼 2022
- Unreal Engine 5
- String
- Basic
- Class
- parameter
Archives
- Today
- Total
행복한 개구리
C++ Tutorial - Arrays / Arrays and Loops 본문
배열을 통하는 반복문
당신은 for 반복문을 통해 배열의 요소들을 훑을 수 있습니다.
아래의 예시는 cars 배열의 모든 요소를 출력합니다.
예시
#include <iostream>
using namespace std;
int main() {
string cars[4] = { "Volvo", "BMW", "Ford", "Mazda" };
for (int i = 0; i < 4; i++) {
cout << cars[i] << "\n";
}
}
아래의 예시에서는 인덱스와 배열의 인덱스에 해당하는 요소의 값을 함께 출력합니다.
예시
#include <iostream>
using namespace std;
int main() {
string cars[4] = { "Volvo", "BMW", "Ford", "Mazda" };
for (int i = 0; i < 4; i++) {
cout << i << ": " << cars[i] << "\n";
}
}
'C++ > 공부내용' 카테고리의 다른 글
C++ Tutorial - Arrays / Get Array Size (0) | 2022.06.22 |
---|---|
C++ Tutorial - Arrays / Omit Array Size (0) | 2022.06.22 |
C++ Tutorial - Arrays / Arrays (0) | 2022.06.21 |
C++ Tutorial - Break/Continue (0) | 2022.06.21 |
C++ Tutorial - For Loop (0) | 2022.06.18 |