My issue
please give me the answer
My code
#include <stdio.h>
// Replace '_' to solve the problem
void sort(int *arr, int n) {
for(int i = 0; i < n; i++) {
int min_val = arr[i];
int min_idx = i;
for(int j = i + 1; j < n; j++) {
if(i>j) {
temp = arr[j];
arr[j] = j;
}
}
int temp = arr[i];
arr[i] = arr[min_idx];
arr[min_idx] = temp;
}
}
int main() {
int n;
scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
sort(arr, n);
for(int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}
printf("\n");
return 0;
}
Learning course: Analysis and Design of Algorithms
Problem Link: Selection Sort in Analysis and Design of Algorithms