当前位置:网站首页>1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)
1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)
2022-04-23 14:26:00 【Zinksl】
:::info
according to Forgetting curve : If there is no record and review ,6 Days later, I will forget 75% The content of
Reading notes are a tool to help you record and review , Don't stick to form , Its core is : Record 、 Look over 、 reflection
:::
Conditions for using loops :
An operation needs to be repeated several times

1 for loop
for Recycle format
for Circular use format :
stay for In circulation , The initialization statement only executes 1 Time ;
for Circular case 1 Output three paragraphs in succession
//for Circular format :
for( Initialization statement ; Conditional statements ; Conditional control statements ){
// Loop body statement ;
}
//for Circular case :
public static void main(String[] args) {
for(int i =0;i<3;i++){
System.out.println(" Execution section "+i+" Secondary cycle !");
}
}
for Circular execution flow ( A top priority )
Perform process resolution , Statement module division , The illustration
for( Initialization statement ; Conditional statements ; Conditional control statements ){
// Loop body statement ;
}

- for Circular case 2( The countdown to dry food )
//for Circular case 2( Dry meal countdown )
for (int i=10;i>=0;i--){
if (i !=0 ){
System.out.println(" The countdown to dinner and "+i+" second ");
}else {
System.out.println(" It's time to start cooking !");
}
}
- for Circular case 3(1-100 Even and )
//for Circular case 3(1-100 Between even numbers and )
// Implementation scheme 1
int sum =0;
for (int i = 1;i<=100;i++){
if (i%2==0){
sum += i;
}
}
System.out.println("1-100 The even number between and is :"+sum);
// Implementation scheme 2
int sum =0;
for (int i = 2;i<=100;i+=2){
sum += i;
}
System.out.println("1-100 The even number between and is :"+sum);
版权声明
本文为[Zinksl]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231412046329.html
边栏推荐
- async void 导致程序崩溃
- 顺序栈的基本操作
- 网页自适应,等比缩放
- 分分钟掌握---三目运算符(三元运算符)
- AT89C51单片机的数字电压表开发,量程0~5V,proteus仿真,原理图PCB和C程序等
- Proteus simulation design of four storey and eight storey elevator control system, 51 single chip microcomputer, with simulation and keil c code
- 直流可调稳压电源的Proteus仿真设计(附仿真+论文等资料)
- LotusDB 设计与实现—1 基本概念
- 基于TLC5615的多路可调数控直流稳压电源,51单片机,含Proteus仿真和C代码等
- ssh限制登录的四种手段
猜你喜欢

setcontext getcontext makecontext swapcontext

Tongxin UOS php7 2.3 upgrade to php7.0 two point two four

KVM learning resources

Qt实战:云曦聊天室篇

PWM speed regulation control system of DC motor based on 51 single chip microcomputer (with complete set of data such as Proteus simulation + C program)

查找水仙花数-for循环实践

uni-app消息推送

Mq-2 and DS18B20 fire temperature smoke alarm system design, 51 single chip microcomputer, with simulation, C code, schematic diagram, PCB, etc

x509证书cer格式转pem格式

关于UDP接收icmp端口不可达(port unreachable)
随机推荐
Four ways of SSH restricting login
redis的五种数据类型
flannel 原理 之 TUN模式
SHT11传感器的温度湿度监控报警系统单片机Proteus设计(附仿真+论文+程序等)
关于在vs中使用scanf不安全的问题
在电视屏幕上进行debug调试
Qt界面优化:Qt去边框与窗体圆角化
API Gateway/API 网关(三) - Kong的使用 - 限流rate limiting(redis)
Redis源码分析之PSYNC同步
ie8 浏览器提示是否 阻止访问js脚本
ssh限制登录的四种手段
剑指offer刷题(2)--面向华为
xx项目架构随记
IE8 browser prompts whether to block access to JS script
Solve the problem of SSH configuration file optimization and slow connection
OpenFaaS实战之四:模板操作(template)
Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
逻辑卷创建与扩容
C语言知识点精细详解——数据类型和变量【1】——进位计数制