当前位置:网站首页>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
边栏推荐
- LM317的直流可调稳压电源Multisim仿真设计(附仿真+论文+参考资料)
- ie8 浏览器提示是否 阻止访问js脚本
- IE8 browser prompts whether to block access to JS script
- Processing MKDIR: unable to create directory 'AAA': read only file system
- AT89C51单片机的数字电压表开发,量程0~5V,proteus仿真,原理图PCB和C程序等
- uni-app消息推送
- Tongxin UOS uninstall php7 2.24, install php7 4.27 ; Uninstall and then install PHP 7.2.34
- 百度笔试2022.4.12+编程题目:简单整数问题
- 循环队列的基本操作(实验)
- Web page, adaptive, proportional scaling
猜你喜欢
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 uninstall php7 2.24, install php7 4.27 ; Uninstall and then install PHP 7.2.34
flannel 原理 之 TUN模式
API Gateway/API 网关(四) - Kong的使用 - 集成Jwt和熔断插件
交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)
Qt实战:云曦聊天室篇
XX project structure notes
KVM学习资源
Proteus simulation design of four storey and eight storey elevator control system, 51 single chip microcomputer, with simulation and keil c code
Man man notes and @ reboot usage of crontab
随机推荐
Wechat applet rotation map swiper
TLS/SSL 协议详解 (28) TLS 1.0、TLS 1.1、TLS 1.2之间的区别
Introduction to the use of semaphore for inter thread control
After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
async void 导致程序崩溃
Use of ansible and common modules
555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
555定时器+74系列芯片搭建八路抢答器,30s倒计时,附Proteus仿真等
xx项目架构随记
js 格式化时间
数组模拟队列进阶版本——环形队列(真正意义上的排队)
循环队列的基本操作,你学会了吗?
Proteus simulation design of four storey and eight storey elevator control system, 51 single chip microcomputer, with simulation and keil c code
SED 学以致用
顺序栈的基本操作
C语言知识点精细详解——数据类型和变量【2】——整型变量与常量【1】
剑指offer刷题(1)--面向华为
八路抢答器系统51单片机设计【附Proteus仿真、C程序、原理图及PCB文件、元器件清单和论文等】
Electronic perpetual calendar of DS1302_ 51 single chip microcomputer, month, day, week, hour, minute and second, lunar calendar and temperature, with alarm clock and complete set of data
Docker (V) MySQL installation