for、while、do-while

for循环结构:
1.格式:
①初始化条件
②循环条件
③迭代条件
④循环体
for(①;②;③){
//④
}
2.执行过程:①-②-④-③-②-④-③-。。。-④-③-②
即直至循环条件不知足,退出当前的循环for循环

 

while循环结构:循环

①初始化条件
②循环条件
③迭代条件
④循环体
1.格式:

while(②){


}
2.for循环与while能够相互转换。while

 

do-while循环结构:

①初始化条件
②循环条件
③迭代条件
④循环体

1.格式:

do{


}while(②);

2.do-while与while的区别:do-while循环至少会执行一次!

相关文章
相关标签/搜索