Break与Continue的区别
2016-01-02 11:15
288 查看
break 是直接跳出循环,执行循环后面的语句
continue 是结束本次循环,但不跳出循环,继续下次循环
第一个循环的输出为0
第二个循环的输出为5、6、7
continue 是结束本次循环,但不跳出循环,继续下次循环
#include <iostream> using namespace std; int main() { for(int i = 0; i<4; i++) { if(i == 0) { std::cout<<i<<std::endl; break; } } for(int j = 5; j<8; j++) { if(j == 6) { std::cout<<j<<std::endl; continue; } std::cout<<j<<std::endl; } return 0; }
第一个循环的输出为0
第二个循环的输出为5、6、7
相关文章推荐
- 设置UICollectionViewCell的尺寸/间距等
- CGRectInset CGRectoffset UIEdgeInsetsInsetRect 这三个函数的使用情况
- Leetcode: Range Sum Query - Mutable
- IO 延迟与Queue Depth
- UICollectionViewCell复用
- Spark UI (基于Yarn) 分析与定制
- UITableViewCell的contentView中的UITextField的值获取的方法
- sunnyxx大神优化UITableViewCell高度计算的那些事
- arduino ide的串口权限解决
- 极客DIY:使用Arduino制作一块开源手表
- Leetcode: Shortest Distance from All Buildings
- Leetcode-52.N-Queens
- SelectedValue 失效
- UNIX环境高级编程__针对apue.h找不到的情况以及log错误信息输出的问题
- UI中如何用纯代码的方式来实现一个图片轮播器
- document.form.command.value
- 代理设计模式在 UIScrollView 中的应用
- UITableView
- 使ViewStub 来提高UI的加载的性能
- UIScrollView无法滚动可能的原因及解决办法分析