1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
|
1 static int minimum (int[] a) {
2 if (a. length > 0) {
3 int m = a [0];
4 int i = 0;
5 int j = 1;
6 while (j < a. length ) {
7 if (a[j] < m) {
8 i = j;
9 m = a[j];
10 }
11 j++;
12 }
13 return i;
14 } else {
15 throw new RuntimeException (" minimum not defined ");
16 }
17 }
|