FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/day21/code/java/ForTest6.java at master · annjeff/Java · GitHub
annjeff
/
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
/
ForTest6.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (31 loc) · 613 Bytes
Breadcrumbs
Java
/
day21
/
code
/
java
/
ForTest6.java
Copy path
File metadata and controls
35 lines (31 loc) · 613 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
/*
需求:请统计1-1000之间同时满足如下条件的数据有多少个:
对3整除余2
对5整除余3
对7整除余2
分析:
A:定义一个统计变量。
B:1-1000之间告诉我们了范围,用for循环可以解决
C:条件
对3整除余2
对5整除余3
对7整除余2
x%3 == 2
x%5 == 3
x%7 == 2
*/
class
ForTest6
{
public
static
void
main
(
String
[]
args
) {
//定义一个统计变量。
int
count
=
0
;
//1-1000之间告诉我们了范围,用for循环可以解决
for
(
int
x
=
1
;
x
<=
1000
;
x
++) {
//判断条件
if
(
x
%
3
==
2
&&
x
%
5
==
3
&&
x
%
7
==
2
) {
//System.out.println(x);
count
++;
}
}
System
.
out
.
println
(
"共有"
+
count
+
"个满足条件的数据"
);
}
}
Back
|
FazBrowse Home
|
New Git URL