Description
void selectionSort(double list[], int arraySize)
Hint
You should submit the implementation of the function but do not submit the main() function.
Problem Source: 程序设计I Chapter6 Arrays
Source.h
void selectionSort(double arr[], int n);
// Date:2020/4/24
// Author:xiezhg5
void selectionSort(double list[], int arraySize) {
//选择排序是基本算法
int i,j;
for(i=arraySize-1; i>=0; i--) {
double max=list[0];
int maxindex=0;
for(j=1; j<=i; j++) {
if(list[j]>max) {
max=list[j]; //首先找到列表中最大元素
maxindex=j; //将其放置在列表末尾
}
}
if(maxindex!=i) {
list[maxindex]=list[i]; //剩余元素中求最大元
list[i]=max; //将其放置在列表次末尾
}
}
}