当前位置:网站首页>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;
}
}
边栏推荐
- 使用3DMAX制作一枚手雷
- 明星开店,退,退,退
- 能源行业的数字化“新”运维
- Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
- 为啥有些线上演唱会总是怪怪的?
- Li Kou brush question diary /day5/2022.6.27
- How to improve development quality
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- 一、C语言入门基础
- 股价大跌、市值缩水,奈雪推出虚拟股票,深陷擦边球争议
猜你喜欢
An example of multi module collaboration based on NCF
Numpy 的仿制 2
Li Kou brush question diary /day7/2022.6.29
Once the "king of color TV", he sold pork before delisting
【2022年江西省研究生数学建模】水汽过饱和的核化除霾 思路分析及代码实现
机器学习概念漂移检测方法(Aporia)
[HCIA continuous update] WAN technology
输入的查询SQL语句,是如何执行的?
2022年全国CMMI认证补贴政策|昌旭咨询
明星开店,退,退,退
随机推荐
力扣刷题日记/day4/6.26
How to improve development quality
曾经的“彩电大王”,退市前卖猪肉
被忽视的问题:测试环境配置管理
未来几年中,软件测试的几大趋势是什么?
Make a grenade with 3DMAX
Stars open stores, return, return, return
The money circle boss, who is richer than Li Ka Shing, has just bought a building in Saudi Arabia
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
[cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
俄罗斯 Arenadata 发布基于PostgreSQL的产品
MySQL common add, delete, modify and query operations (crud)
Analysis of I2C adapter driver of s5pv210 chip (i2c-s3c2410. C)
[proteus simulation] printf debugging output example based on VSM serial port
Android uses sqliteopenhelper to flash back
Device interface analysis of the adapter of I2C subsystem (I2C dev.c file analysis)
蓝桥:合根植物
Is it safe to open an account online? is that true?
SIGMOD’22 HiEngine论文解读
File processing examples of fopen, FREAD, fwrite, fseek