summaryrefslogtreecommitdiffstats
path: root/sorts.c
diff options
context:
space:
mode:
Diffstat (limited to 'sorts.c')
-rw-r--r--sorts.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sorts.c b/sorts.c
index 6cc74dc..c0342aa 100644
--- a/sorts.c
+++ b/sorts.c
@@ -17,7 +17,7 @@
#define ARR_RANGE 99
#define ELEM_LINE 10
#define FNAME "sort.txt"
-#undef PRINT_FILE
+#undef PRINT_FILE
/* global */
FILE *out = NULL;
@@ -222,18 +222,24 @@ void print_arr(int *arr, int elem)
int i;
for (i = 1; i < elem + 1; i++)
{
- fprintf(out, "%3d ", *(arr + i - 1) );
+ fprintf(out, "%3d", *(arr + i - 1) );
+
if ( (i % ELEM_LINE == 0) && i != 0)
fprintf(out, "\n");
+ else
+ fprintf(out, " ");
}
fprintf(out, "\n");
#else
int i;
for (i = 1; i < elem + 1; i++)
{
- printf("%3d ", *(arr + i - 1) );
+ printf("%3d", *(arr + i - 1) );
+
if ( (i % ELEM_LINE == 0) && i != 0)
printf("\n");
+ else
+ printf(" ");
}
printf("\n");
#endif
@@ -279,12 +285,12 @@ int main(int argc, char **argv)
#endif
print_arr(arr, ARR_SIZE);
- bubble_sort(arr, ARR_SIZE);
+ //bubble_sort(arr, ARR_SIZE);
//select_sort(arr, ARR_SIZE);
//insrt_sort(arr, ARR_SIZE);
//mergesort(arr, 0, ARR_SIZE - 1);
//shell_sort(arr, ARR_SIZE);
- //quicksort(0, ARR_SIZE, arr);
+ quicksort(0, ARR_SIZE, arr);
#ifdef PRINT_FILE
fprintf(out, "sorted:\n");