просто тестирую методы сортировки, и я столкнулся с сортировкой выбора. Я понял логи c за сортировкой выбора, но я не получаю желаемый результат, который я sh вижу из этой программы. Это не похоже на сортировку вообще. Может кто-нибудь сказать мне, где я ошибся.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int StudentCreation(int StudentRecordArray[10]){
for(int i = 0; i < 10; i++){
StudentRecordArray[i] = rand() % 100; //limiting the marks range from 0 - 100
}
}
int SelectionSort(int SelectionSortarray[]) {
int n = 0;
int tmp = 0;
for(int j = 0; j < 10-1; j++){
int TempMinimum = j;
for(int i = j+1; i < n; i++)
if(SelectionSortarray[i] < SelectionSortarray[TempMinimum])
TempMinimum = i;
if(TempMinimum != j){
tmp = SelectionSortarray[j];
SelectionSortarray[j] = SelectionSortarray[TempMinimum];
SelectionSortarray[TempMinimum] = tmp;
}
}
for (int f = 0; f < 10; f++){
printf("Student %d - %d\n", f+1, SelectionSortarray[f]);
}
}
int main() {
int StudentRecord[10];
int MenuChoice;
srand(time(NULL)); //random number seed generator
StudentCreation(StudentRecord);
printf("the unsorted list:\n");
for (int f = 0; f < 10; f++){
printf("Student %d - %d\n", f+1, StudentRecord[f]);
}
printf("\nthe sorted list:\n\n");
SelectionSort(StudentRecord);
return 0;
}
Что-то не так с тем, где я поменялся местами?