-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProg3.java
More file actions
34 lines (31 loc) · 673 Bytes
/
Prog3.java
File metadata and controls
34 lines (31 loc) · 673 Bytes
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
package org.project.test;
/**
* 判断水仙花数
* @author zgp
*
*/
public class Prog3 {
public static void main(String[] args){
for(int i=100;i<1000;i++){
if(isLotus(i))
System.out.print(i+" ");
}
System.out.println();
}
//判断水仙花数
private static boolean isLotus(int lotus){
int m = 0;
int n = lotus;
int sum = 0;
m = n/100;
n -= m*100;
sum = m*m*m;
m = n/10;
n -= m*10;
sum += m*m*m + n*n*n;
if(sum==lotus)
return true;
else
return false;
}
}