Try this and see if it works for you
Code:
#include <stdio.h>
int find_max(int[], int);
int find_min(int[], int);
int get_min_range(double list[], int first, int last);
void sel_sort(int list[], int n);
int main(void){
int nums[] = {5, 3, 0, 9, 8, 1, 7, 4, 10, 2};
int i = 0;
printf("\n\nThe maximum value is %d. \n", find_max(nums, 10));
printf("\nThe minimum value is %d. \n", find_min(nums, 10));
sel_sort(nums, 10);
while( i < 10 ){
printf("\nThe ascending order of the array is %d \n", nums[i]);
i++;
}
return(0);
}
int find_max(int last[], int num_ele){
int i, max = last[0];
for(i = 0; i < num_ele; i++)
if(max > last[i]) max = last[i];
return max;
}
int find_min(int first[], int num_ele){
int i, min = first[0];
for(i = 0; i < num_ele; i++)
if(min < first[i]) min = first[i];
return min;
}
int get_min_range( double list[], int first, int last){
int i, small_sub;
small_sub = first;
for(i = first + 1; i <= last; ++i)
small_sub = i;
return(small_sub);
}
void sel_sort(int *list, int n){
int temp;
for(int i = 0; i < n - 1; i++){
int min = i;
for( int j = i + 1; j < n; j++){
if(list[j] < list[min]) { min = j; }
}
temp = list[min];
list[min] = list[i];
list[i] = temp;
}
}
-Prelude