FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/day21/code/java/ForTest3.java at master · devenc/Java · GitHub
devenc
/
Java
Public
forked from
DuGuQiuBai/Java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
day21
/
code
/
java
/
ForTest3.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (33 loc) · 645 Bytes
Breadcrumbs
Java
/
day21
/
code
/
java
/
ForTest3.java
Copy path
File metadata and controls
43 lines (33 loc) · 645 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class
ForTest3
{
public
static
void
main
(
String
[]
args
) {
//求出1-100之间偶数和
/*
//定义求和变量
int sum = 0;
//通过for循环获取每一个数据
for(int x=1; x<=100; x++) {
//把数据累加
sum += x;
}
//输出结果
System.out.println("1-100之和:"+sum);
System.out.println("---------------");
*/
//偶数:能被2整除的数据
//如何判断数据是否能够被整出呢? x%2 == 0
/*
int sum = 0;
for(int x=1; x<=100; x++) {
if(x%2 == 0) {
sum += x;
}
}
System.out.println("1-100的偶数和:"+sum);
*/
int
sum
=
0
;
for
(
int
x
=
0
;
x
<=
100
;
x
+=
2
) {
sum
+=
x
;
}
System
.
out
.
println
(
"1-100的偶数和:"
+
sum
);
}
}
Back
|
FazBrowse Home
|
New Git URL