当前位置:网站首页>Li Kou brush question diary /day4/6.26
Li Kou brush question diary /day4/6.26
2022-07-04 18:35:00 【Bobo toilet cleaning spirit】
Novice Village
Sunrise Sunset , There is always dawn
VScode function java project
Create a new window
CTRL+SHIFT+P, Enter... In the pop-up window create java, choice No build tools
Select a folder to store java Project code
Set project name
You can run java Code
while loop
do while loop
do{
Code block
}while( Boolean expression );
do while Loop at least once , Because execute first do sentence , Then execute the judgment statement while, So execute the code block content at least once .
while loop
while( expression ){
Code block ;
// Jump out of while Circular approach
if(){
break
}
}
while(1)、while(2)、while(3) Both indicate that the condition is true , That is to say, not 0 The numbers of all mean true .
while If the expression of the loop is not satisfied , Do not execute once .
Self incrementing sign i++ and ++i
i++ First operation , One more
++i Yes, add one first , Re operation
Java in i=i++ and i++
In the above code , The last output i The value of is always 0,
because i First assign to i by 0, After one execution ,i The value of is 0, Proceed again i=i++, The assignment operation has been assigning i=0.
Modify the code
The above code can realize i A change in the value of ,while Statement executed n Time ,i The value is n
Example
Their thinking : First define the number of operations i, Create a while loop , Judge num Is it even , If yes num=num/2, No num=num-1.i++, Record the number of executions , Last return i
class Solution {
public int numberOfSteps(int num) {
int i=0;
while(num != 0){
if(num % 2 == 0){
num=num/2;
}
else{
num=num-1;
}
i++;
}
return i;
}
}
边栏推荐
- Interpretation of SIGMOD '22 hiengine paper
- Li Kou brush question diary /day6/6.28
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- 2022 national CMMI certification subsidy policy | Changxu consulting
- [proteus simulation] printf debugging output example based on VSM serial port
- I always thought that excel and PPT could only be used for making statements until I saw this set of templates (attached)
- Blue bridge: sympodial plant
- Li Kou brush question diary /day7/2022.6.29
- TCP两次挥手,你见过吗?那四次握手呢?
- Introduction of time related knowledge in kernel
猜你喜欢
庆贺!科蓝SUNDB与中创软件完成七大产品的兼容性适配
爬虫初级学习
Make a grenade with 3DMAX
DB-Engines 2022年7月数据库排行榜:Microsoft SQL Server 大涨,Oracle 大跌
Machine learning concept drift detection method (Apria)
【Hot100】32. Longest valid bracket
Reptile elementary learning
谷粒商城(一)
celebrate! Kelan sundb and Zhongchuang software complete the compatibility adaptation of seven products
Li Kou brush question diary /day7/6.30
随机推荐
Implementation of shell script replacement function
未来几年中,软件测试的几大趋势是什么?
蓝桥:合根植物
vbs或vbe如何修改图标
Li Kou brush question diary /day8/7.1
[210] usage of PHP delimiter
90后开始攒钱植发,又一个IPO来了
File processing examples of fopen, FREAD, fwrite, fseek
删除二叉搜索树中的节点附图详解
How to open an account is safe,
明星开店,退,退,退
Mysql5.7 installation tutorial graphic explanation
如何提高开发质量
力扣刷题日记/day6/6.28
机器学习概念漂移检测方法(Aporia)
创业两年,一家小VC的自我反思
Introduction of time related knowledge in kernel
估值900亿,超级芯片IPO来了
ITSS运维能力成熟度分级详解|一文搞清ITSS证书
【Go语言刷题篇】Go完结篇|函数、结构体、接口、错误入门学习