当前位置:网站首页>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
边栏推荐
猜你喜欢

TLS/SSL 协议详解 (28) TLS 1.0、TLS 1.1、TLS 1.2之间的区别

API Gateway/API 网关(三) - Kong的使用 - 限流rate limiting(redis)

AT89C51 MCU digital voltmeter development, measuring range 0 ~ 5V, proteus simulation, schematic diagram, PCB and C program, etc

AT89C51单片机的数字电压表开发,量程0~5V,proteus仿真,原理图PCB和C程序等

AT89C52单片机的频率计(1HZ~20MHZ)设计,LCD1602显示,含仿真、原理图、PCB与代码等

常见存储类型和FTP主被动模式解析

uni-app消息推送

51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等

Matlab Simulink modeling and design of single-phase AC-AC frequency converter, with MATLAB simulation, PPT and papers

C语言知识点精细详解——初识C语言【1】
随机推荐
LM317的直流可调稳压电源Multisim仿真设计(附仿真+论文+参考资料)
MySQL同步Could not find first log file name in binary log index file错误
Docker (V) MySQL installation
Docker篇 (五) MySQL的安装
redis的五种数据类型
顺序栈的基本操作
API Gateway/API 网关(四) - Kong的使用 - 集成Jwt和熔断插件
Usage of BC
修改Firebase Emulators的默认侦听IP
uni-app消息推送
统信UOS PHP7.2.3升级至PHP7.2.24
js 抛物线运动方法封装
Redis cluster 原理
MQ-2和DS18B20的火灾温度-烟雾报警系统设计,51单片机,附仿真、C代码、原理图和PCB等
基础正则表达式
Introduction to loan market quotation interest rate (LPR) and loan benchmark interest rate
Solve the problem of SSH configuration file optimization and slow connection
Debug on TV screen
初始c语言大致框架适合复习和初步认识
本以为能躺着进华为,结果陆续收到京东/滴滴/爱奇艺offer的我迷茫了