第二十二篇:for循环语句

for循环语句的一般格式为:  

for(表达式1;表达式2;表达式3)

 { 循环体语句 }

该语句的执行过程是:

 ① 执行for后面的表达式1;

 ② 执行表达式2,若表达式2的值为真,则执行for语句的内嵌语句(即循环体语句);若为假,则循环结束,执行for语句的循环体下面的语句;

 ③ 执行表达式3;  

 ④ 执行第②步;

第二十二篇:for循环语句

 1 #include<iostream>
 2 
 3 using namespace std;
 4 
 5 int main()
 6 
 7 {
 8 
 9 for (int i = 0;i<10;i++)//(变量,判断,步长)
10 
11 {
12 
13 cout<<i<<endl;//输出
14 
15 }
16 
17 }

 

 

 

转载于:https://www.cnblogs.com/GodPan/articles/3229138.html