控制(补充
条件控制
作用域 定义变量只在{}内部生效
初始化 if(int pow = x * x; pow < 100)
通常书写
1 | if (x < 0) { |
书写规范:同样如果只有一行代码可写成一行增加代码的可阅读性
if(condition) only_one_statement
循环控制
1 | for(init; condition;iteration){ |
循环嵌套
示例九九乘法表
1 | for(int a = 1; a <= 9; a++){ |
跳转控制
break 打破循环,直接结束循环
coutinue 继续循环 跳过后续未执行的循环体,跳到迭代语句和循环条件之前
goto 任意跳转至某一个标签
1 | label: |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Frite的个人博客!