当前位置:网站首页>03|Process Control
03|Process Control
2022-08-10 01:47:00 【farming garden】
1 if statement
1.1 syntax
if(expression)
{
Execute action
}
1.2 Complex logic
Associative operator precedence writing condition:
- Highest priority: ()
- Lowest priority:=
- Priority: !>Arithmetic Operators>Relational Operators>&& >||
Note: Use parentheses for complex conditions to improve readability
1.3 Multiple if
- Syntax: if----else if --else
- if can only be in the first place, and there must be one
- else, only at the last and at most one
- else if in the middle, there can be several (0-n)
- if-else-if-else: It is judged from top to bottom, and the first result is true, execute the code, after the code block is executed, jump out
1.4 Nested if selection structure
- In order to make the code more readable, higher and more logical
- In a single code block, it is best not to exceed three levels of nesting at a time. If it exceeds, check the logic
2 swith statement
- The condition is not a boolean type, except for long unexpected integer + enumeration + string+char after jdk (1.7)
- The swtich comparison must be the equivalent judgment of the constant and the constant cannot be repeated
- break, prevent penetration
- switch is a separate scope
- switch does not need a comparison, finds the target at one time 6. defautl, when all conditions are not satisfied, execute default; it may or may not be
- can be in any position, but usually, we habitually put it at the first or at the end; if it is not at the end, we usually add break.
3 loops
3.1 while loop
3.1.1 Syntax
while(loop condition)
{
Execute action
}
3.1.2 The Four Steps of the Cycle
- Initial Conditions: Where to Start
- Judging conditions, where does it end
- The body of the loop is the main content of the loop execution
- Iteration: infinite approach to the goal
3.1.3 The difference between while and do-while loops
- When the condition is not met, do not execute it once; first judge that it is executing
- When the do-while loop, when the conditions are met, execute at least once; execute first, then judge
- Loops have fixed and variable lengths
- Order and Flashback
- Define step size
- Multiple criteria
3.2 for loop
3.2.1 Syntax
for(parameter initialization; conditional judgment; update loop variable)
{
Execute operation
}
For example: For( ; ; ){}
3.3 Jump and Skip
3.3.1 Syntax
Break //Jump out of all loops (only valid for the current loop)
Continue //Skip this loop (only valid for the current loop)
3.4 Flowchart
边栏推荐
猜你喜欢
[C language] In-depth understanding of pointers and arrays (issue 4)
JVM Memory and Garbage Collection - 10. Direct Memory
Mysql数据库 ALTER 基本操作
FITC标记生物素(FITC-生物素|CAS:134759-22-1)有哪些知识了?
【数据存储】signed,unsigned到底怎么区分?如何计算?
2022金九银十工作潮,怎么样才能成功跳槽面试拿到高薪呢?
共创 Ray 中文社区,Ray Forward Meetup 2022 直播邀你参加!
C语言--数据的存储(上)
pytest:如何在测试中编写和报告断言
3.9 - 正规表达式和正规集 3.10 - 有限自动机
随机推荐
E - Sugoroku 3(期望dp)
微信公众号如何开通支付功能?
输入的这些数是否对称
win10重装系统后没声音怎么办?
聚焦热点 | ISC 2022软件供应链安全治理与运营论坛圆满落幕
openEuler 知:abi 检测
JVM内存和垃圾回收-10.直接内存
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
WPF DataGrid using data templates
Fury:一个基于JIT动态编译的高性能多语言原生序列化框架
arm-4-裸板开发
-骑士巡游-
[C language] Address book "Static Memory Version"
Project (7) - PolarSeg point cloud semantic segmentation
Kubernetes服务接入Istio
NTP SERVICE TASK 在GWserver配置、启用NTP服务,为当前环境提供时钟同步服务,Client主机可以从该服务器同步时间。
线程的同步与互斥
What should I do if there is no sound after reinstalling the system in win10?
Win7怎么把控制面板添加到右键菜单
构建平衡二叉树「建议收藏」