-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc3f43d
commit 450629e
Showing
38 changed files
with
238 additions
and
5 deletions.
There are no files selected for viewing
Binary file modified
BIN
+195 Bytes
(110%)
out/production/Java_Task/Unit_2/Test_1/AreaAndLength.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+261 Bytes
(120%)
out/production/Java_Task/Unit_2/Test_1/DataTypeDome.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+167 Bytes
(110%)
out/production/Java_Task/Unit_2/Test_2/BitShiftDome.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+108 Bytes
(110%)
out/production/Java_Task/Unit_2/Test_2/OperationDome.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+172 Bytes
(110%)
out/production/Java_Task/Unit_3/Test_1/LeapYearDemo.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+221 Bytes
(120%)
out/production/Java_Task/Unit_3/Test_1/ScoreChange2.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package Unit_3.Test_3; | ||
|
||
public class DaffodilNumber { | ||
private void DealNum(int i) { | ||
int a = i % 10; | ||
int b = i / 10 % 10; | ||
int c = i / 100; | ||
if (a * a * a + b * b * b + c * c * c == i) { | ||
System.out.println(i); | ||
} | ||
} | ||
|
||
public void ForDemo() { | ||
for (int i = 100; i < 1000; i++) { | ||
DealNum(i); | ||
} | ||
} | ||
|
||
public void WhileDemo() { | ||
int i = 100; | ||
while (i < 1000) { | ||
DealNum(i); | ||
i++; | ||
} | ||
} | ||
|
||
public void DoWhileDemo() { | ||
int i = 100; | ||
do { | ||
DealNum(i); | ||
i++; | ||
} while (i < 1000); | ||
} | ||
|
||
public static void main(String[] args) { | ||
DaffodilNumber daffodilNumber = new DaffodilNumber(); | ||
daffodilNumber.ForDemo(); | ||
System.out.println("----"); | ||
daffodilNumber.WhileDemo(); | ||
System.out.println("----"); | ||
daffodilNumber.DoWhileDemo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package Unit_3.Test_3; | ||
|
||
public class DegreeChangeDemo { | ||
public static void main(String[] args) { | ||
int h, c; | ||
System.out.println("摄氏温度\t华氏温度"); | ||
for (c = 0; c <= 40; c += 5) { | ||
h = c * 9 / 5 + 32; | ||
System.out.println("\t" + c + "\t" + h); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package Unit_3.Test_3; | ||
|
||
public class Factorial { | ||
public static void main(String[] args) { | ||
long result = 1; | ||
for (int i = 2; i < 21; i++) { | ||
result *= i; | ||
} | ||
System.out.println("20的阶乘为:" + result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package Unit_3.Test_3; | ||
|
||
public class ForLoop { | ||
public static void main(String[] args) { | ||
int limit = 100; | ||
int sum = 0; | ||
//下面这行代码利用for循环实现求和算法 | ||
for (int i = 1; i <= limit; i++) { | ||
sum += i; | ||
} | ||
System.out.println("sum = " + sum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package Unit_3.Test_3; | ||
|
||
public class NMumDemo { | ||
public static void main(String[] args) { | ||
int i, j, n = 9; | ||
System.out.print(" * |"); | ||
for (i = 1; i <= n; i++) { | ||
System.out.print("\t" + i); | ||
} | ||
System.out.print("\n---|"); | ||
for (i = 1; i <=n ; i++) { | ||
System.out.print("----"); | ||
} | ||
System.out.println(); | ||
for (i = 1; i <= n; i++) { | ||
System.out.print(" " + i + " |"); | ||
for (j = 1; j <= i; j++) { | ||
System.out.print("\t" + i * j); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package Unit_3.Test_3; | ||
|
||
public class NumDemo { | ||
public static void main(String[] args) { | ||
int n; | ||
System.out.println("在1~1000可被3与5整除的为"); | ||
for (n = 0; n <= 1000; n++) { | ||
if (n % 3 == 0 && n % 5 == 0) { | ||
System.out.println(n); | ||
} | ||
} | ||
System.out.println(" "); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package Unit_4.Test_1; | ||
|
||
public class ArrayDeclare { | ||
public static void main(String[] args) { | ||
int[] i = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
for (int j = 0; j < i.length; j++) { | ||
System.out.print(i[j] + " "); | ||
} | ||
System.out.println(); | ||
for (int j = i.length - 1; j > -1; j--) { | ||
System.out.print(i[j] + " "); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package Unit_4.Test_1; | ||
|
||
import java.util.Random; | ||
|
||
public class ArrayRandom { | ||
public static void main(String[] args) { | ||
Random rand = new Random(); | ||
int[] a = new int[rand.nextInt(20)]; | ||
double[] b = new double[rand.nextInt(20)]; | ||
System.out.println("a" + a.length); | ||
System.out.println("b" + b.length); | ||
for (int i = 0; i < a.length; i++) { | ||
a[i] = rand.nextInt(20); | ||
System.out.println("a[" + i + "]=" + a[i]); | ||
} | ||
for (int i = 0; i < b.length; i++) { | ||
b[i] = rand.nextDouble(); | ||
b[i] = b[i] + a[i]; | ||
System.out.println("b[" + i + "]=" + b[i]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package Unit_4.Test_1; | ||
|
||
public class ArraySort { | ||
public static void main(String[] args) { | ||
int a[] = {20, 10, 50, 40, 30, 70, 60, 80, 90, 100}; | ||
int temp; | ||
for (int i = 0; i < a.length - 1; i++) { | ||
for (int j = i + 1; j < a.length; j++) { | ||
if (a[i] < a[j]) { | ||
temp = a[i]; | ||
a[i] = a[j]; | ||
a[j] = temp; | ||
} | ||
} | ||
} | ||
for (int k = 0; k < a.length; k++) { | ||
System.out.print(" " + a[k]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package Unit_4.Test_1; | ||
|
||
public class Fibonacci { | ||
public static void main(String[] args) { | ||
int[] f = new int[10]; | ||
f[0] = f[1] = 1; | ||
for (int i = 2; i < 10; i++) { | ||
f[i] = f[i - 1] + f[i - 2]; | ||
} | ||
for (int e : f) { | ||
System.out.print(e + " "); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package Unit_4.Test_1; | ||
|
||
public class GetDay { | ||
public static void main(String[] args) { | ||
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
for (int i = 0; i < 12; i++) { | ||
System.out.println((i + 1) + "月有" + day[i] + "天"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package Unit_4.Test_1; | ||
|
||
public class MaxAndMin { | ||
public static void main(String[] args) { | ||
int[] a = {2, 4, 6, 3, 9, 1}; | ||
int min = a[0], max = a[0]; | ||
for (int i = 1; i < a.length; i++) { | ||
if (a[i] < min) { | ||
min = a[i]; | ||
} | ||
if (a[i] > max) { | ||
max = a[i]; | ||
} | ||
} | ||
System.out.println("最小值:" + min + ";" + "最大值:" + max); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package Unit_4.Test_1; | ||
|
||
public class Score { | ||
public static void main(String[] args) { | ||
int[] score = new int[]{12, 32, 45, 56, 67, 87, 98}; | ||
for (int i = 0; i < score.length; i++) { | ||
System.out.println(score[i]); | ||
} | ||
} | ||
} |