Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

randomSort

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

Name: Anonymous 2008-04-12 1:21

I use a printersort.

1) Print out all the numbers, one number per sheet of paper. Use 200 point arial.
2) Hand out numbers to people who are good at math
3) Have them sort the numbers
4) Use OCR software to scan the numbers back in order

You now have a sorted list.

Bonus: It's the only sort in the world with an unpredictable error rate.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List