当前位置:网站首页>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();
}
}
}
}
}边栏推荐
- Yolov5 realizes road crack detection
- Sv806 QT UI development
- Common MySQL date query
- 2022 fusion welding and thermal cutting recurrent training question bank and simulation examination
- Soil type, soil texture, soil nutrient and change data, soil organic matter, soil pH, soil nitrogen, phosphorus and potassium
- Things to challenge
- Some optimization methods for UI Application of Qt5 on Hisilicon security platform
- [backtracking] backtracking method to solve combinatorial problems
- Minigui3 runs on Hisilicon hi3520d/hi3531 platform
- Yolo opencv scale identification scale reading identification water gauge identification water level identification source code
猜你喜欢

Bearpi IOT serial port transceiver 1- normal mode

National land use data of 30m precision secondary classification

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

AI and logistics Patent

Jwt Learning and use

Redis learning notes (continuously updating)

2022 self study materials for Zhejiang computer level III network and security technology examination (1) (updated on 2.28)

Normalized vegetation index (NDVI) data, NPP data, GPP data, evapotranspiration data, vegetation type data, ecosystem type distribution data

Sentinel-2 data introduction and download

Simple Tetris
随机推荐
Drive safety coding & troubleshooting guide
Some problems of silly girl solved
Parallélisation de l'entraînement accéléré TF. Données. Générateur de données
From science to startup
How to deploy dolphin scheduler Apache dolphin scheduler 1.2.0 in cdh5.16.2
[backtracking] backtracking to solve subset problems
Yolo opencv scale identification scale reading identification water gauge identification water level identification source code
Harris corner detection principle-
AI and logistics Patent
@What happens if bean and @component are used on the same class?
Self implementation of a UI Library - UI core drawing layer management
Difference between thread and task
Realease package appears – missing type parameter
According to aiqicha, keep went public in Hong Kong and hit the "first share of online fitness"
National land use data of 30m precision secondary classification
Image processing 13- calculation of integral diagram
22-2-28 there are many things to do at work today, ETH analysis
2022 fusion welding and thermal cutting recurrent training question bank and simulation examination
When the build When gradle does not load the dependencies, and you need to add a download path in libraries, the path in gradle is not a direct downloadable path
Chapter 1