Name: Anonymous 2008-04-07 11:06
#include <cstdio>
#include <ctime>
#include <cstdlib>
using namespace std;
bool isSorted(int* list, int l)
{
for (int i=1; i<l; i++)
if (list[i-1]>list[i])
return false;
return true;
}
int*& randomSort(int*& list, int l)
{
int i;
int j;
int temp;
srand(time(0));
while (!isSorted(list,l))
{
i=rand()%l;
j=rand()%l;
temp = list[i];
list[i] = list[j];
list[j] = temp;
}
return list;
}
int main(void)
{
int k=14;
int* a = new int[15];
for (int i=0; i<15; i++)
a[i]=k--;
a = randomSort(a,15);
for(int i=0; i<15; i++)
printf("%d ",a[i]);
return 0;
}
//NO ONE CAN FUCKING TOP THIS