-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathTask11Main.java
More file actions
38 lines (28 loc) · 1.01 KB
/
Task11Main.java
File metadata and controls
38 lines (28 loc) · 1.01 KB
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
33
34
35
36
37
38
package com.example.task11;
public class Task11Main {
public static void main(String[] args) {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:
int[] arr = {7, 5, 9};
swap(arr);
System.out.println(java.util.Arrays.toString(arr));
}
static void swap(int[] arr) {
//todo напишите здесь свою корректную реализацию этого метода, вместо существующей
if (arr == null || arr.length == 0){
return;
}
int min = Integer.MAX_VALUE;
int index = 0;
int indexMin = 0;
for (int i : arr){
if (i <= min){
min = i;
indexMin = index;
}
index += 1;
}
arr[indexMin] = arr[0];
arr[0] = min;
}
}