控制语句结构
来源:互联网 发布:软件系统测试手册 编辑:程序博客网 时间:2024/06/11 05:56
if
if (x == 100) cout << "x is 100";
if (x == 100){ cout << "x is "; cout << x;}
if (x == 100) cout << "x is 100";else cout << "x is not 100";
if (x > 0) cout << "x is positive";else if (x < 0) cout << "x is negative";else cout << "x is 0";
while
while (n>0) { cout << n << ", "; --n; }
do while
do { cout << "Enter number (0 to end): "; cin >> n; cout << "You entered: " << n << "\n"; } while (n != 0);
for (int n=10; n>0; n--) { cout << n << ", "; }
for ( n=0, i=100 ; n!=i ; n++, i-- ){ // whatever here...}
break
for (n=10; n>0; n--) { cout << n << ", "; if (n==3) { cout << "countdown aborted!"; break; } }
continue
for (int n=10; n>0; n--) { if (n==5) continue; cout << n << ", "; }
goto
int main (){ int n=10; loop: cout << n << ", "; n--; if (n>0) goto loop; cout << "FIRE!\n"; return 0;}
switch (x) { case 1: cout << "x is 1"; break; case 2: cout << "x is 2"; break; default: cout << "value of x unknown"; }
switch (x) { case 1: case 2: case 3: cout << "x is 1, 2 or 3"; break; default: cout << "x is not 1, 2 nor 3"; }
int x = 10;
int y=0;
switch (x) { case 10:
y=30; default: y+=20; }
//y == 50
- 控制语句结构
- Lua控制结构语句
- lua控制结构语句
- shell控制结构语句
- C++控制结构-控制结构跳转语句
- C++控制结构-循环语句
- C++控制结构-条件语句
- Matlab:3 控制结构语句
- ruby 语句和控制结构
- 流程控制语句--顺序结构
- 流程控制语句--选择结构
- 流程控制语句--循环结构
- 控制结构和循环语句
- 【shell】结构控制-判断语句
- 【shell】结构控制-循环语句
- 【C】控制结构和语句
- 嵌套的控制结构、其他控制语句
- 结构控制语句与函数的调用
- HTTP协议详解
- 第8周项目:工资问题
- WAP项目开发总结
- NSIS杂项
- oracle数据库常见问题集锦
- 控制语句结构
- UITabBarController学习笔记
- 对嵌入式Linux中的根文件系统的理解和解析
- mongodb的查询方式与sql语句对比
- Cocos2d-x 动作之瞬时动作
- SNMP MIB中的含read-create节点的表的实现
- 国际知名大学计算机视觉研究小组列表
- ScrollView中嵌套GridView,Listview的办法
- hiRedis Synchronous API