当前位置:网站首页>Three types of cyclic structure
Three types of cyclic structure
2022-04-23 03:28:00 【Aiyou coffee】
Cycle structure is divided into cycle condition and cycle operation .
A circular statement should have four parts : initialization , conditional , The loop body , iteration .
while loop :
At the beginning of recirculation , The accountant calculates once “ Boolean expression ” Value , If the condition is true , Execution loop body . And for every subsequent extra frontal circulation , Will be calculated again before starting again .
There should be statements in the statement that make the loop tend to end , Otherwise, there will be an infinite loop -----“ die ” loop
do-while loop :
Execute it once and judge whether it is correct at the beginning
while And do-while The difference between : An execution before judgment , A judge before execution .do-while Always ensure that the loop body is executed at least once . therefore while Execute before judge ,do-while Judge before you execute .
for loop :
for Loop is a general structure that supports iteration , Is the most effective , Is the most flexible loop structure
Grammatical form :
for( Initial expression ; Boolean expression ; Walk ){
The loop body
}
matters needing attention :
for After the loop performs the conditional test , Do the program first , And then step ;
stay for The variables declared in the initialization part of the statement , Its scope is the whole for The loop body ;
“ initialization ” and “ Loop expression ” Part can use commas to perform multiple operations ;
If all three parts are empty ( A semicolon ; Energy saving ), It's like an infinite loop ;
Multiple cycles :
Three cycles :while,do-while,for
Multiple cycles ( Nested loop )
A circulatory body also includes another complete circulatory structure
Any two loops can be nested with each other
You can loop at any level , But it usually doesn't exceed 3 layer
Multiple loop execution process : The multi-layer cyclic variable changes once , The inner loop variable changes again
Use in multiple loops continue
版权声明
本文为[Aiyou coffee]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619008945.html
边栏推荐
- MySql关键字GROUP_CONCAT,组合连接查询
- . net 5 Web custom middleware implementation returns the default picture
- 移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
- Chapter 7 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of modular programming exercises with functions
- 深度学习笔记(二)——激活函数原理与实现
- Can you answer the questions that cannot be answered with a monthly salary of 10k-20k?
- Section 1 array and slicing in Chapter 6
- 2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
- C-11 problem I: find balloon
- Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
猜你喜欢
Section 2 map and structure in Chapter 6
Redis(17) -- Redis缓存相关问题解决
浅学一下I/O流和File类文件操作
JS inheritance
深度学习笔记(二)——激活函数原理与实现
Super easy to use [general excel import function]
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
File upload vulnerability summary and upload labs shooting range documentary
"Visual programming" test paper
随机推荐
2021-08-31
关于idea调试模式下启动特别慢的优化
Scenario Title: how does system a use the page of system B
The query type of MySQL is very inefficient.
Applet - WXS
Experiment 6 input / output stream
Cefsharp stores cookies and reads cookies
. net 5 Web custom middleware implementation returns the default picture
JS takes out the same elements in two arrays
File upload vulnerability summary and upload labs shooting range documentary
Visual programming -- how to customize the mouse cursor
oracle 查询外键含有逗号分隔的数据
7-3 poly width
Experiment 5 components and event handling
JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
A comprehensive understanding of static code analysis
Fiddler use
Supersocket is Use in net5 - startup
socket編程 send()與 recv()函數詳解