C++中 for(; ;) 循环语句
来源:互联网 发布:linux optargs 编辑:程序博客网 时间:2024/05/16 14:31
#include <iostream>using namespace std;int main(){int j = 1;for (int i = 0; i < 5;j = ++i){cout << "i = " << i << endl;cout << "j = " << j << endl;}cout << endl;j = 1;for (int i = 0; i < 5;){cout << "i = " << i << endl;cout << "j = " << j << endl;j = ++i;}cout << endl;j = 0;for (int i = 0; i < 5; j = i++){cout << "i = " << i << endl;cout << "j = " << j << endl;}return 0;}
从以上的运行结果可以看出,第一个for()循环语句和第二个for()循环语句的作用相同,运行结果一样,可以看出for()循环中三条语句首先进行附初值,之后进行判断,然后进行for()循环体内的运算,最后进行for()内的最后一条语句运算。
从第二和第三个for()循环中可以看出,++i是先自加,后赋值,i++则是先赋值,后进行自加运算。
- C ++ 中 的 for 循环语句
- C-012.for循环语句
- C 中for 循环语句执行顺序之我是汇编
- C/C++中for()循环中的判断语句
- C++中 for(; ;) 循环语句
- java中for循环语句
- C语言中循环结构语句 for循环及while,do--while 的使用
- C语言之while循环语句和do while循环语句、for循环语句、循环嵌套
- 4.4 C语言for循环语句
- 6.15C循环控制语句for while
- C语言for循环break语句
- 循环语句for语句
- 循环语句--for语句
- for循环语句中得continue
- ASP中For…Next循环语句
- 4.4 Swift中for循环语句
- 4.5 Swift中for in 循环语句
- C++中for循环语句简析
- GDB调试精粹及使用实例
- WIN7 & V.C60 & Visual_AssistX
- target is null for setProperty(null, "x", [Ljava.lang.String;@b0c40e)错误异常
- android通知
- NSTimer的用法
- C++中 for(; ;) 循环语句
- 给Label随机分配背景颜色
- Oralce如何避免no data found
- 字符串匹配之sunday算法
- webservice之CXF注解实现(一)
- C#中对串口的操作
- idea intellij混淆android代码
- 数据库学习--INTERSECT ALL (SQL Server)
- __try,__except,__finally,__leave