Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion task12/src/com.example.task12/Task12Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,26 @@ public static void main(String[] args) {
}

static void selectionSort(int[] arr) {
//todo напишите здесь свою корректную реализацию этого метода, вместо существующей
if (arr == null || arr.length == 0)
return;

int firstIndex = 0;

while (firstIndex < arr.length) {

int index = 0;
int minNumb = Integer.MAX_VALUE;
for (int i = firstIndex; i < arr.length; i++) {
if (arr[i] <= minNumb) {
minNumb = arr[i];
index = i;
}
}
arr[index] = arr[firstIndex];
arr[firstIndex] = minNumb;

firstIndex++;
}
}

}