Beispiel #1
0
perm_list permutations( int_list the_x )
{
    x = the_x;
    perm_CONS( the_x, 0, perms );
    P( int_list_length( the_x ) );
    return perms;
}
Beispiel #2
0
void quicksort( int_list *l )
{
  int *A = malloc( int_list_length(l)*sizeof(int) );
  size_t k;
  
  k = 0;
  ABL_BEGIN_LOOP( int_list, l ){
    A[k++] = *int_list_get_point( l );
  } ABL_END_LOOP( int_list, l );
Beispiel #3
0
int compare( const void* pa, const void *pb)
{
  return (*(int*)pa) - (*(int*)pb);
}

void quicksort( int_list *l )
{
  int *A = malloc( int_list_length(l)*sizeof(int) );
  size_t k;
  
  k = 0;
  ABL_BEGIN_LOOP( int_list, l ){
    A[k++] = *int_list_get_point( l );
  } ABL_END_LOOP( int_list, l );
  qsort( A, int_list_length(l), sizeof(int), compare );

  k = 0;
  ABL_BEGIN_LOOP( int_list, l ){
    *int_list_get_point( l ) = A[k++];
  } ABL_END_LOOP( int_list, l );

  free(A);
}


int main()
{
  int_list ilst, ilst_comb, ilst_merge, ilst_quick;
  /* list of ints */
  int i;			/* iterator */