Skip to content

Commit

Permalink
第三单元收尾,第四单元完成实验一
Browse files Browse the repository at this point in the history
  • Loading branch information
1374363910 committed Jun 28, 2019
1 parent bc3f43d commit 450629e
Show file tree
Hide file tree
Showing 38 changed files with 238 additions and 5 deletions.
Binary file modified out/production/Java_Task/Unit_2/Test_1/AreaAndLength.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_1/ByteTest.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_1/CharTest.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_1/Circle.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_1/DataTypeDome.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_1/Ladder.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_1/Triangle.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_2/BitShiftDome.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_2/CircleArea.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_2/DivModDome.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_2/MySumDemo.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_2/OperationDome.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_2/Test_2/SanmuTest.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/DegreeDemo.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/LeapYearDemo.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/MaxMinDemo.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/PresentDemo.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/ScoreChange.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/ScoreChange2.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_1/UpperOrLower.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_2/DealNumber.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_2/DoWhileDemo.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_2/GuessNumber.class
Binary file not shown.
Binary file modified out/production/Java_Task/Unit_3/Test_2/WhileDemo.class
Binary file not shown.
20 changes: 15 additions & 5 deletions src/Unit_3/Test_2/Sort.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package Unit_3.Test_2;

import java.util.List;

public class Sort implements SortInterface {
private int[] record;//定义待排序序列

//构造函数,初始化序列
public Sort(int[] record) {
private Sort(int[] record) {
this.record = record;
}
@Override
Expand Down Expand Up @@ -61,7 +63,6 @@ public void bubbleSort() {
@Override
public void quickSort(int first, int end) {
if (first >= end) {
return;
} else {
int pivot = partition(first, end);
quickSort(first, pivot - 1);
Expand Down Expand Up @@ -157,8 +158,17 @@ public void mergeSort2() {

}

@Override
public void print() {

@Override
public void print() {
for (int e : record) {
System.out.print(e + " ");
}
}

public static void main(String[] args) {
int[] list = {10,3,9,4,11,13,5,2};
Sort sort = new Sort(list);
sort.insertSort();
sort.print();
}
}
43 changes: 43 additions & 0 deletions src/Unit_3/Test_3/DaffodilNumber.java
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();
}
}
12 changes: 12 additions & 0 deletions src/Unit_3/Test_3/DegreeChangeDemo.java
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);
}
}
}
11 changes: 11 additions & 0 deletions src/Unit_3/Test_3/Factorial.java
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);
}
}
13 changes: 13 additions & 0 deletions src/Unit_3/Test_3/ForLoop.java
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);
}
}
23 changes: 23 additions & 0 deletions src/Unit_3/Test_3/NMumDemo.java
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();
}
}
}
14 changes: 14 additions & 0 deletions src/Unit_3/Test_3/NumDemo.java
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(" ");
}
}
14 changes: 14 additions & 0 deletions src/Unit_4/Test_1/ArrayDeclare.java
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] + " ");
}
}
}
22 changes: 22 additions & 0 deletions src/Unit_4/Test_1/ArrayRandom.java
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]);
}
}
}
20 changes: 20 additions & 0 deletions src/Unit_4/Test_1/ArraySort.java
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]);
}
}
}
14 changes: 14 additions & 0 deletions src/Unit_4/Test_1/Fibonacci.java
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 + " ");
}
}
}
10 changes: 10 additions & 0 deletions src/Unit_4/Test_1/GetDay.java
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] + "天");
}
}
}
17 changes: 17 additions & 0 deletions src/Unit_4/Test_1/MaxAndMin.java
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);
}
}
10 changes: 10 additions & 0 deletions src/Unit_4/Test_1/Score.java
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]);
}
}
}

0 comments on commit 450629e

Please sign in to comment.