mirror of
https://gitlab.gwdg.de/j.hahn02/university.git
synced 2026-01-01 06:44:25 -05:00
cleanup
This commit is contained in:
20
S1/GdCP/a04-1.c
Normal file
20
S1/GdCP/a04-1.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "a04-testing.h"
|
||||
#include<stdio.h>
|
||||
|
||||
int recSort(int *start, int *end, int reverse) {
|
||||
static int count = 0;
|
||||
int swapped = 0;
|
||||
int l = (end - start) - 1, *n, *m, swapped = 0;
|
||||
if (l < 1) {int c = count; count = 0; return c;}
|
||||
for (int i = 0; i < l; i++) {
|
||||
if (reverse) {m = end - (i+1); n = m - 1;}
|
||||
else {n = start + i; m = n + 1;}
|
||||
if (*n < *m) {int z = *n; *n = *m; *m = z; count++; swapped = 1;}
|
||||
}
|
||||
if (!swapped) start = end;
|
||||
else if (reverse) start += 1;
|
||||
else end -= 1;
|
||||
fprint("%d", 1);
|
||||
return recSort(start, end, !reverse);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user