#include<iostream>
#include<conio.h>
using namespace std;
void selectionSort(int numbers[], int array_size) //function for sorting
{
int i, j, T, min;
for (i = 0; i < array_size; i++)
{
min = i;
for (j = i + 1; j < array_size; j++)
{
if (numbers[j] < numbers[min])
{
min = j;
}
}
T = numbers[min];
numbers[min] = numbers[i];
numbers[i] = T;
cout<<numbers[i]<<" ";
}
}
void main()
{
int numbers[5]={5,3,1,2,4};
int b=5;
cout<<"selection sorting : ";
selectionSort(numbers,b);
cout<<" ";
getch();
}
#include<conio.h>
using namespace std;
void selectionSort(int numbers[], int array_size) //function for sorting
{
int i, j, T, min;
for (i = 0; i < array_size; i++)
{
min = i;
for (j = i + 1; j < array_size; j++)
{
if (numbers[j] < numbers[min])
{
min = j;
}
}
T = numbers[min];
numbers[min] = numbers[i];
numbers[i] = T;
cout<<numbers[i]<<" ";
}
}
void main()
{
int numbers[5]={5,3,1,2,4};
int b=5;
cout<<"selection sorting : ";
selectionSort(numbers,b);
cout<<" ";
getch();
}
No comments:
Post a Comment