当前位置:网站首页>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
边栏推荐
- QT uses drag and drop picture to control and mouse to move picture
- Learn about I / O flow and file operations
- Un aperçu des flux d'E / s et des opérations de fichiers de classe de fichiers
- New ORM framework -- Introduction to beetlsql
- Téléchargement en vrac de fichiers - téléchargement après compression
- File upload vulnerability summary and upload labs shooting range documentary
- 全新的ORM框架——BeetlSQL介绍
- Applet - more than two pieces of folding and expansion logic
- 2022 团体程序设计天梯赛 模拟赛 1-8 均是素数 (20 分)
- JS takes out the same elements in two arrays
猜你喜欢

Visual programming - Experiment 1

Test questions and some space wars

MySql关键字GROUP_CONCAT,组合连接查询

Why is bi so important to enterprises?

Development record of primary sensitive word detection

2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)

Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)

C set

MySQL query specifies that a row is sorted to the first row

you need to be root to perform this command
随机推荐
Scenario Title: how does system a use the page of system B
Unity knowledge points (ugui)
Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)
Optimization of especially slow startup in idea debugging mode
Visual programming -- how to customize the mouse cursor
Cefsharp stores cookies and reads cookies
2022 group programming ladder simulation match 1-8 are prime numbers (20 points)
Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
Unity knowledge points (common core classes)
"Visual programming" test paper
打卡:4.23 C语言篇 -(1)初识C语言 - (12)结构体
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
Oracle query foreign keys contain comma separated data
TCP three handshakes and four waves
全新的ORM框架——BeetlSQL介绍
you need to be root to perform this command
String input problem
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
Unity basics 2
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