refactor various files

This commit is contained in:
2025-04-28 16:59:44 +02:00
parent 5049c3ec13
commit 05c830c8e2
97 changed files with 513 additions and 2676 deletions

28
S1/GdCP/uebung/a03.c Normal file
View File

@@ -0,0 +1,28 @@
typedef struct interval_s {
long low; // lower bound
long up; // upper bound
} interval_t;
long max(long a, long b) {
if (a > b) return a;
return b;
}
long min(long a, long b) {
if (a > b) return b;
return a;
}
int is_empty(const interval_t *a) {
return a->low > a-> up;
}
int is_empty_intersection(const struct interval_s *a, const struct interval_s *b) {
if (!a || !b) return 1;
const interval_t *l[] = {a, b};
for (int i = 0; i < 2; i++) {
if (is_empty(l[i])) return 1;
}
interval_t s = {max(a->low, b->low), min(a->up, b->up)};
return is_empty(&s);
};