Mercurial > hg > Members > taiki > cbc_test
view quick_sort/quick_sort.cbc @ 9:2ce34a5ff69b default tip
add pointer test
author | taiki |
---|---|
date | Tue, 08 Jan 2013 12:34:40 +0900 |
parents | 2698082de0ea |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <time.h> enum SetValue { ARRAY_MAX = 20, COUNT_START_VALUE = 0, }; __code quick_sort(int *int_array) { } // init array by random value. __code init_random(int *int_array, int count) { if (count < ARRAY_MAX) { *(int_array + count) = (int)(rand() * (ARRAY_MAX + 1.0)/(RAND_MAX + 1.0)); printf("[%d] %d \n", count, *(int_array + count)); count++; goto init_random(int_array, count); } else { printf("\n"); goto quick_sort(int_array); } } void make_array() { int *int_array = malloc(ARRAY_MAX * sizeof(int)); srand((unsigned int)time(NULL)); goto init_random(int_array, COUNT_START_VALUE); } int main() { make_array(); return 0; }