-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction1.java
More file actions
32 lines (31 loc) · 827 Bytes
/
Function1.java
File metadata and controls
32 lines (31 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class Function1 {
public static int min(int a[]) {
int minElement = a[0];
for (int i = 0; i < a.length; i++) {
if (minElement > a[i]) {
minElement = a[i];
}
}
return minElement;
}
public static int max(int a[]) {
int maxElement = a[0];
for (int i = 0; i < a.length; i++) {
if (maxElement < a[i]) {
maxElement = a[i];
}
}
return maxElement;
}
public static int sum(int a[]) {
int sumElement = 0;
for (int i = 0; i < a.length; i++) {
sumElement += a[i];
}
return sumElement;
}
public static void main(String[] args) {
int a[] = {1, -5, 4, 7, 8, 10};
System.out.println(min(a) +" " + max(a) + " " + sum(a));
}
}