Provide Best Programming Tutorials

## (指定等级）

• 如果分数>=best-10, 等级为A

• 如果分数>=best-20, 等级为B

• 如果分数>=best-30, 等级为C

• 如果分数>=卜68140, 等级为D

• 其他情况下，等级为F

```Enter the number of students: 4
Enter 4 scores: 40 55 70 58
Student 0 score is 40 and grade is C
Student 1 score is 55 and grade is B
Student 2 score is 70 and grade is A
Student 3 score is 58 and grade is B```

## (计算数字的出现次數）

```Enter the integers between 1 and 100: 2 5 6 5 4 3 23 43 2 0
2 occurs 2 times
3 occurs 1 time
4 occurs 1 time
5 occurs 2 times
6 occurs 1 time
23 occurs 1 time
43 occurs 1 time```

## (统计一位数的个數）

〆提示：使用（int)(Math.random()*10)产生0 到9 之间的随机整數。使用一个名为counts 的由10 个整数构成的數组存放0,1，…，9 的个数

## (求数组的平均值）

```public static int average(int[] array)
public static double average(double[3 array)
```

## (找出最小元素）

`public static double min(double[] array)`

```Enter ten numbers: 1.9 2.5 3.7 2 1.5 6 3 4 5 2
The minimum number is: 1.5```

## (找出最小元素的下标）

public static int indexOfSmal1estEIement(double[] array)

## (随机数选择器）

`public static int getRandom(int. . . numbers)`

## (计算gcd)

`public static int gcd(int… numbers)`

## (消除重复）

`public static int[] eliminateDuplicates(int[] list)`

```Enter ten numbers: 1 2 3 2 1 6 3 4 5 2
The distinct numbers are: 1 2 3 6 4 5```

## (是否排好序了？）

`public static boolean isSorted(int[] list)`

```Enter list: 8 10 1 5 16 61 9 11 1
The list is not sorted

Enter list: 10 1 1 3 4 4 5 7 9 11 21

## (仿真：优惠券收集人网題）

```Queen of Spades
5 of Clubs
Queen of Hearts
4 of Diamonds
Number of picks: 12```

## ( 完全相同的数组）

`public static boolean equals(int[] listl, int[] 1ist2)`

## (相同的数组）

`public static boolean equals(int[] listl, int[] list2)`

```Enter list1: 5 2 5 6 6 1
Enter list2: 5 5 2 6 1 6
Two lists are identical

Enter list1: 5 5 5 6 6 1
Enter list2: 5 2 5 6 1 6
Two lists are not identical```

## (模式识别方面：四个连续相等的数）

`public static boolean isConsecutiveFour(int[] values)`

```Enter the number of values: 8
Enter the values: 3 4 5 5 5 5 4 5
The list has consecutive fours
Enter the

Enter the number of values: 9
Enter the values: 3 4 5 5 6 5 5 4 5
The list has no consecutive fours```

## (合并两个有序列表）

`public static int[] merge(int[] listl, int[] list2)`

```Enter list1: 5 1 5 16 61 111
Enter list2: 4 2 4 5 6
The merged list is 1 2 4 5 5 6 16 61 111```

## ( 对字符串中的字符排序）

`public static String sortCString s)`

## ( 游戏：猜字游戏）

```// Add any words you wish in this array
String[] words = {"write", "that", ...};```
```(Guess) Enter a letter in word ******* > p
(Guess) Enter a letter in word p****** > r
(Guess) Enter a letter in word pr**r** > p
p is already in the word
(Guess) Enter a letter in word pr**r** > o
(Guess) Enter a letter in word pro*r** > g
(Guess) Enter a letter in word progr** > n
n is not in the word
(Guess) Enter a letter in word progr** > m
(Guess) Enter a letter in word progr*m > a
The word is program. You missed 1 time
Do you want to guess another word? Enter y or n>
Programming Exercises 285```

## 参考答案

https://github.com/AndrewProgramming/JavaProgrammingHomework/tree/master/src/chpater_array