当前位置:网站首页>12.24 day exercise -- Programming summation, 99 multiplication table, while loop and for loop exercises
12.24 day exercise -- Programming summation, 99 multiplication table, while loop and for loop exercises
2022-06-12 04:59:00 【なんでもないゃ】
Programming summation : ∑1+∑2+∑3+……+∑100 =1 +(1+2)+(1+2+3)+(...)+(1+2+3+4+5+…+100)
package Play;
// Programming summation :
//∑1+∑2+∑3+……+∑100
//=1 +(1+2)+(1+2+3)+(...)+(1+2+3+4+5+…+100)
public class Sum {
public static void main(String[] args) {
int sum=0;
int SUM=0;
for(int i=1;i<=3;i++){
for(int j=0;j<=i;j++){
sum+=j;
}
// SUM+=sum; If you put it here, the answer is 15
}
SUM+=sum;
System.out.println("∑1+∑2+∑3+……+∑100:"+SUM);// Output 10
}
}
Be confused :SUM+=sum Must be on for Outside of the loop , Unresolved
multiplication table
public class JiuJiu {
public static void main(String[] args) {
//1*1=1 xy
//1*2=2 2*2=4 x y+1 x+1 y+1
//1*3=3 2*3=6 3*3=9 x y+2 x+1 y+2 x+2 y+2
//1*4=4 2*4=8 3*4=12
//······
//1*9=9 2*9=18 3*9=27······9*9=81
for(int i=1;i<=9;i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + "*" + i + "=" + j * i+" ");
}
System.out.println();
}
}
while Circulation and for Circulation practice
public class Thousand {
public static void main(String[] args) {
// use while and for Cyclic output 1-1000 Can be 5 Divisible number , And each line outputs 3 individual
System.out.println("*************while loop *************");
int i=1;
int j=0;
while(i<=1000){
if(i%5==0){
System.out.print(i+"\t");
j++;
if(j%3==0){
System.out.println();
}
}
i++;
}
System.out.println();
System.out.println("**************for loop **************");
for(int m=1,n=0;m<=1000;m++){
if(m%5==0){
System.out.print(m+"\t");
n++;
if(n%3==0){
System.out.println();
}
}
}
}
}边栏推荐
- Realease package appears – missing type parameter
- Soil type, soil texture, soil nutrient and change data, soil organic matter, soil pH, soil nitrogen, phosphorus and potassium
- Microsoft announces that it will discontinue support for older versions of visual studio
- How to generate provincial data from county-level data in ArcGIS?
- Walking "daily question" and "DP"
- [GIS tutorial] land use transfer matrix
- How to construct a search string?
- Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution
- February 19, 2022 [Nolan] Nolan resurrected? Change · Nolan [soul orchid] can be connected to XDD / silly girl
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
猜你喜欢

kali下安装pycharm并创建快捷访问

InnoDB data storage structure – MySQL

L1-067 Roche limit (10 points)

2022“高考记忆” 已打包完成,请查收!

BI 如何让SaaS产品具有 “安全感”和“敏锐感”(上)

CCF access control system
![[GIS tutorial] ArcGIS for sunshine analysis (with exercise data download)](/img/60/baebffb2024ddf5f2cb070f222b257.jpg)
[GIS tutorial] ArcGIS for sunshine analysis (with exercise data download)

SQL injection upload one sentence Trojan horse (turn)

National land use data of 30m precision secondary classification

Transpiration and evapotranspiration (ET) data, potential evapotranspiration, actual evapotranspiration data, temperature data, rainfall data
随机推荐
The master programmer "plays" a C program that is not like C
Acquisition of Lai data, NPP data, GPP data and vegetation coverage data
2022 fusion welding and thermal cutting recurrent training question bank and simulation examination
Introduction to MMS memory optimization of Hisilicon MPP service
Surface net radiation flux data, solar radiation data, rainfall data, air temperature data, sunshine duration, water vapor pressure distribution, wind speed and direction data, surface temperature
Link: fatal error lnk1168: cannot open debug/test Solution of exe for writing
L1-065 "nonsense code" (5 points)
Summary of problems in rv1109/rv1126 product development
Google reinforcement learning framework seed RL environment deployment
MySQL5.7.21 Build For ARM
Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution
Transpiration and evapotranspiration (ET) data, potential evapotranspiration, actual evapotranspiration data, temperature data, rainfall data
Minigui3 runs on Hisilicon hi3520d/hi3531 platform
Qinglong wool - Kaka
How to clear floating, and how does it work?
Things to challenge
Enhanced vegetation index evi, NDVI data, NPP data, GPP data, land use data, vegetation type data, rainfall data
asp. Net core theme Middleware
Sentinel-2 data introduction and download
2022“高考记忆” 已打包完成,请查收!