You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
807 B
41 lines
807 B
#include <stdio.h>
|
|
void selectSort(int arry[], int len)
|
|
{ int i;
|
|
int j;
|
|
for ( i = 0; i < len-1; i++)
|
|
{
|
|
int min = i;
|
|
for (j = i + 1; j < len; j++)
|
|
{
|
|
if (arry[j] < arry[min])
|
|
{
|
|
min = j;
|
|
}
|
|
}
|
|
int temp = arry[min];
|
|
arry[min] = arry[i];
|
|
arry[i] = temp;
|
|
}
|
|
}
|
|
void print(int arry[], int len)
|
|
{
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
printf("%d ", arry[i]);
|
|
}
|
|
}
|
|
int main()
|
|
{
|
|
int arry[10]={15,36,26,27,24,46,44,29,52,48};
|
|
selectSort(arry,10);
|
|
print(arry,10);
|
|
|
|
|
|
printf("\n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|