-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
31 lines (19 loc) · 741 Bytes
/
Main.java
File metadata and controls
31 lines (19 loc) · 741 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
import java.util.Arrays;
class Main{
public static void main(String[] args) {
System.out.println(highAndLow("1 2 3 4 5"));
}
public static String highAndLow(String numbers) {
String result = "";
String[] stringArr = numbers.split(" ");
// 2. int massivi yaradırıq
int[] intArray = new int[stringArr.length];
// 3. String-ləri int-ə çeviririk
for (int i = 0; i < stringArr.length; i++) {
intArray[i] = Integer.parseInt(stringArr[i]);
}
Arrays.sort(intArray);
result = Integer.toString(intArray[intArray.length - 1]) + " " + Integer.toString(intArray[0]);
return result;
}
}