循环
for循环
for(init; condition; increment)
{
conditional code;
}
foreach循环
int myArray[5] = {0,1,2,3,4};
for (const int i : myArray)
{
cout << i << endl;
}
while循环
while(condition)
{
statement(s);
}
do-while循环
do {
statement(s);
}while( condition );
循环控制语句
- break
- continue
- goto
goto label;
label: statement;
分支
if和else语句
if(boolean_expression)
{
}
else
{
}
switch语句
switch(expression)
{
case constant-expression :
statement(s);
break;
case constant-expression :
statement(s);
break;
default :
statement(s);
}
转载请注明出处,本文永久更新链接:https://blogs.littlegenius.xin/2019/08/05/【C-温故知新】三循环与分支/