void SortFunctions::Shuffle(int a[], int sa)
{
int temp,randN, last;
for (last = sa; last > 1; last--)
{
randN = rand() % last;
temp = a[randN];
a[randN] = a[last-1];
a[last-1] = temp;
}
}
bool SortFunctions::Sorted(int a[], int sa)
{
for(int i = 1; i < sa; i++)
{
if (a[i] < a[i-1])
{
return false;
}
}
return true;
}
int SortFunctions::BozoSort(int a[], int sa)
{
while( !Sorted(a,sa))
{
Shuffle(a,sa);
}
return 0;
}
For some reason its not working. can someone tell me what I am doing wrong?

New Topic/Question
Reply




MultiQuote






|