Home > Back-end >  Pray god to help
Pray god to help

Time:11-15

Write selection sort function void the sort (int * array, int n), request to array name as a function of the parameters, the main function of input data and output the sorted elements

CodePudding user response:

refer to the original poster qq_45054817 response:
write selection sort function void the sort (int * array, int n), request to array name as a function of the parameters, the main function of the input data and output the sorted elements

#include
using namespace std;

Void the sort (int * array, int n)
{
int temp;
For (int I=0; i{
Int index=I;
For (int j=I + 1; J & lt; n; J++)
If (array [j] The index=j;
If (index!=I)
{
Temp=array [I];
Array=array [I] [index];
Array [index]=temp;
}
}
}

Int main () {
An int array [8]=,10,5,3,6,8,70,12 {1};
Sort (array, 8);
For (int I=0; i <8; I++) {
Cout & lt; }
Cout & lt;
}

CodePudding user response:

Today just write the selection sort algorithm, can see, let you fully grasp the knowledge, also with the program code, https://blog.csdn.net/weixin_43956598/article/details/90178197
  • Related