changeset 5:77c6ae852e6c

test to write quick_sort.cbc
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Mon, 06 Aug 2012 23:30:27 +0900
parents 0e1afa97fe89
children 7e3fab27a577
files quick_sort.cbc
diffstat 1 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/quick_sort.cbc	Mon Aug 06 23:30:27 2012 +0900
@@ -0,0 +1,44 @@
+#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;
+}