[Arrays]D. Liang 6.15 Revising selection sort
生活随笔
收集整理的這篇文章主要介紹了
[Arrays]D. Liang 6.15 Revising selection sort
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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; //將其放置在列表次末尾}} }總結
以上是生活随笔為你收集整理的[Arrays]D. Liang 6.15 Revising selection sort的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java+ee+网页修改数据库_基于js
- 下一篇: Improving speech rec