This commit is contained in:
2025-04-21 00:40:30 +02:00
parent 9ccc21edde
commit b8c75fc6d3
87 changed files with 2788 additions and 99 deletions

20
S1/GdCP/a04-1.c Normal file
View 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);
};