ํ์
// FORMAT
for (var_type var_name: sequence){
statements; // can use var_name
}
์์ ์ฝ๋
// Example Code
#include <iostream>
using namespace std;
int main(){
vector<int> my_vec {10, 50, 22, 501, 1930};
for (int num:my_vec) {
cout << num << endl; // 10\n50\n22\n501\n1930
}
}
'C++ > ๋ฐ๋ณต๋ฌธ (Loop)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++] do-while Loop (0) | 2023.12.12 |
---|---|
[C++] While Loop (0) | 2023.12.10 |
[C++] Conditional Operator (์กฐ๊ฑด ์ฐ์ฐ์) (2) | 2023.12.08 |