📅  最后修改于: 2022-03-11 14:44:50.371000             🧑  作者: Mango
#include
using namespace std;
int main(){
//selection sort
int a[5] = {54,69,12,2,89};
//find minimum in rest of the array and swap with the current index;
//if(n>1)
for(int i=0;i<5-1;i++)
{
int minloc = i;
for(int j=i+1;j<5;j++)
{
if(a[minloc]>a[j])
{
minloc = j;
}
}
swap(a[i],a[minloc]);
}
for(int i=0;i<5;i++)
{
cout<