الگوریتم مرتب سازی Selection Sort
#include <iostream.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
void selectionSort(int numbers[], int array_size);
void main (void)
{
const n = 10;
int X[n];
randomize();
for (int i=0; i<n; i++)
{
X[i] = rand() % 100;
cout << X[i] << "\t";
}
selectionSort (X, n);
cout<< endl;
for (int i=0; i<n; i++)
cout << X[i] << "\t";
getch();
}
void selectionSort(int arr[], int size)
{
int i, j, min, temp;
for (i = 0; i < size-1; i++)
{
min = i;
for (j = i+1; j < size; j++)
{
if (arr[j] < arr[min])
min = j;
}
temp = arr[i];
arr[i] = arr[min];
arr[min] = temp;
}
}