C语言之break和continue
来源:互联网 发布:js 数组push 编辑:程序博客网 时间:2024/05/17 04:28
break:cause the innermost enclosing loop or switch to be exited immediately.
continue: cause the next iteration of the enclosing for, while, or do loop to begin. The continue statement appliesonly to loops, not to switch. A continue inside a switch inside a loop causes the next loop iteration.
break:导致最内层的封闭循环或者switch立刻退出;
continue:导致for,while,或者do循环的下一个循环开始执行。continue只用在循环中,不用在switch中。一个循环中switch中的continue会导致下一个循环。
#include <stdio.h>
/* test the break and continue */
int main()
{
int i;
for (i = 0; i < 10; i++)
{
switch(i)
{
case 5:
break;
}
printf("%d", i);
}
return 0;
}
/* test the break and continue */
int main()
{
int i;
for (i = 0; i < 10; i++)
{
switch(i)
{
case 5:
break;
}
printf("%d", i);
}
return 0;
}
输出:0 1 2 3 4 5 6 7 8 9
break只是退出了switch,执行了后面的printf
#include <stdio.h>
/* test the break and continue */
int main()
{
int i;
for (i = 0; i < 10; i++)
{
switch(i)
{
case 5:
continue;
}
printf("%d", i);
}
return 0;
}
/* test the break and continue */
int main()
{
int i;
for (i = 0; i < 10; i++)
{
switch(i)
{
case 5:
continue;
}
printf("%d", i);
}
return 0;
}
输出:0 1 2 3 4 6 7 8 9
continue直接执行下一个for循环,没有执行printf
0 0
- C语言之break和continue
- C语言break和continue
- C语言之辅助循环手段continue和break
- c语言 continue break
- C语言--break语句和continue语句
- C语言continue和break有的区别
- C语言continue和break有的区别
- C语言continue 和break的用法
- c 语言break 和 continue的区别
- c语言中的break和continue
- C语言break和continue的区别
- C语言continue和break的区别
- C#:break和continue
- C语言解释器-12 控制结构之break、continue和return
- C语言基础知识之(五):break 和 continue 运用详解
- C语言之循环结构中break、continue、goto、return和exit的区别
- 李洋疯狂C语言之break和continue的区别
- 【c/c++】break和continue
- UITableView 知识更新A table view displays a list of items in a single column. UITableView is a subclas
- Objective-C对象和Core Foundation 对象
- 使用限定符
- javascript经典 面试题及答案
- mysql 卖家数据 查询模板 放在博客里 方便使用
- C语言之break和continue
- Android面试准备:内存泄露和内存溢出
- 组合数学中的项链计数
- 深入理解GPU Architecture
- php的路由规则
- 魔术师的秘密
- Kafka启动,显示内存不足,修改内存项
- 仿QQ顶部圆角页面切换Button
- Failed to load libGL.so error libGL.so: cannot open shared object file: No such file or directory