Skip to content

Commit c78f8c0

Browse files
committed
算法
1 parent cde64c2 commit c78f8c0

13 files changed

+160
-0
lines changed

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Algorithm40</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8

bin/ConditionUse.class

1.02 KB
Binary file not shown.

bin/Daffodil.class

722 Bytes
Binary file not shown.

bin/MyMath.class

473 Bytes
Binary file not shown.

bin/PrimeDivide.class

1.21 KB
Binary file not shown.

bin/PrimeNumber.class

1003 Bytes
Binary file not shown.

bin/RabbitBirth.class

735 Bytes
Binary file not shown.

src/ConditionUse.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.Scanner;
2+
3+
public class ConditionUse {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
8+
System.out.println("input the score:");
9+
Scanner sc=new Scanner(System.in);
10+
int score=sc.nextInt();
11+
evaluate(score);
12+
sc.close();
13+
System.exit(0);
14+
15+
16+
}
17+
18+
public static void evaluate(int score){
19+
String str=(score>90?"A":(score>60?"B":"C"));
20+
System.out.println(str);
21+
}
22+
23+
}

src/Daffodil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* 打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个
3+
* 三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三次方+5的三次方+3的三次方。
4+
*/
5+
public class Daffodil {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
System.out.println("hh");
10+
MyMath mymath=new MyMath();
11+
for(int i=100;i<1000;i++){
12+
if(mymath.isDaffodil(i)==true)
13+
System.out.println(i);
14+
}
15+
16+
17+
}
18+
}
19+
class MyMath{
20+
public boolean isDaffodil(int number){
21+
int s=0;
22+
int count=0;
23+
while(number!=0){
24+
s= number%10;
25+
count=count+s*s*s;
26+
number=number/10;
27+
}
28+
return count==number;
29+
}
30+
}

0 commit comments

Comments
 (0)