当前位置:网站首页>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
边栏推荐
- 数组模拟队列进阶版本——环形队列(真正意义上的排队)
- Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
- grep无法重定向到文件的问题
- 分分钟掌握---三目运算符(三元运算符)
- Nacos作为配置中心(四) 使用Demo
- sar命令详解
- 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)
- Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
- LM317的直流可调稳压电源Multisim仿真设计(附仿真+论文+参考资料)
- DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料
猜你喜欢
redis的五种数据类型
顺序表的操作,你真的学会了吗?
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【2】
51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等
API Gateway/API 网关(二) - Kong的使用 - 负载均衡Loadbalance
差分隐私(背景介绍)
进入新公司,运维工程师从下面这几项了解系统的部署
Electronic scale weighing system design, hx711 pressure sensor, 51 single chip microcomputer (proteus simulation, C program, schematic diagram, thesis and other complete data)
DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料
flannel 原理 之 TUN模式
随机推荐
gif转为静态图片处理
Use of ansible and common modules
51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等
setcontext getcontext makecontext swapcontext
555定时器+74系列芯片搭建八路抢答器,30s倒计时,附Proteus仿真等
流程控制之分支语句
循环队列的基本操作,你学会了吗?
顺序表的操作,你真的学会了吗?
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【1】
Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【2】
Nacos作为配置中心(四) 使用Demo
AT89C52 MCU frequency meter (1Hz ~ 20MHz) design, LCD1602 display, including simulation, schematic diagram, PCB and code, etc
Usage of BC
ssh限制登录的四种手段
ansible及常用模块的使用
1分钟看懂执行流程,永久掌握for循环(附for循环案例)
man man随记和crontab的@reboot用法
ie8 浏览器提示是否 阻止访问js脚本
js 进度条,显示加载进度