Beispiel #1
0
int main(int argc, char **argv)
{
/*
	int v[10] = {16, 4, 10, 14, 7, 9, 3, 2, 8, 1};
	int size = 10;
*/
	//int v[8] = { 2, 1, 3, 8, 7, 5, 6, 4 };
	int v[8] = { 2, 8, 7, 1, 3, 5, 6, 4 };
	int *c;
	int size = 8;
	int i;

	printf("original array\n");
	print_array(v, size);

	/* insertion sort */
	printf("\tinsert sort\n");
	c = clone_array(v, size);
	insertion(c, size);
	print_array(c, size);
	free(c);

	/* merge sort */
	printf("\tmerge sort\n");
	c = clone_array(v, size);
	merge(c, size);
	print_array(c, size);
	free(c);

	/* bubble sort */
	printf("\tbubble sort\n");
	c = clone_array(v, size);
	bubblesort(c, size);
	print_array(c, size);
	free(c);

	/* heap sort */
	printf("\theap sort\n");
	c = clone_array(v, size);
	heapsort(c, size);
	print_array(c, size);
	free(c);

	/* quicksort */
	printf("\tquicksort\n");
	c = clone_array(v, size);
	quicksort(c, size);
	print_array(c, size);
	free(c);

	return 0;
}
Beispiel #2
0
static VALUE rb_array_clamp(VALUE self, VALUE rect)
{
	return rb_array_clamp_bang(clone_array(self), rect);
}
Beispiel #3
0
static VALUE rb_array_union(VALUE self, VALUE other_rect)
{
	return rb_array_union_bang(clone_array(self), other_rect);
}
Beispiel #4
0
static VALUE rb_array_inflate(VALUE self, VALUE size)
{
	return rb_array_inflate_bang(clone_array(self), size);
}
Beispiel #5
0
static VALUE rb_array_move(VALUE self, VALUE delta)
{
	return rb_array_move_bang(clone_array(self), delta);
}
Beispiel #6
0
static VALUE rb_array_normalize(VALUE self)
{
	VALUE retval=clone_array(self);
	normalize(retval);
	return retval;
}