its not correctly assigning items in an array during the sorting function of selection sort in c++.what is the correct way?
int a[] = { 22, 91, 35, 78, 10, 8, 75, 99, 1, 67 };
int arr_len = sizeof(a)/sizeof(a[0]);
for(int index = 0; index < arr_len - 1; index++)
{
for(int n = index + 1; n < arr_len; n++)
{
if(a[index] > a[n])
{
a[index] = a[n];
a[n] = a[index];
}
}
}
the result of my program gave me like this: Array in sorted order: 1 1 1 1 1 1 1 1 1 67
a=bfollowed byb=awill make botha,b = btemp=a; a=b; b= temp;std::swap.std::sizecan be used to replacesizeof(a)/sizeof(a[0])