blob: aa4f7c063683c8cb3575fb493aa5ef8675a4ee71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <stdio.h>
typedef struct _Cell {
Formation* val;
struct _Cell* next;
} Cell;
typedef struct _Formation {
char* name;
int hours;
Cell* formations;
} Formation;
typedef struct{
int length;
int max;
Formations** formations;
} Catalogue;
void print_formation(Formation* f){
if (f->hours != 0) {
printf("Cours %s\n", f->name);
return;
}
printf("%s (%d): ", f->name, f->hours);
Cell* fms = f->formations;
while (fms) {
print_formation(fms->val);
fms = fms->next;
}
printf("\n");
}
void print_catalogue(Catalogue* c){
for (int i = 0; i < c->lenght; i++) {
print_formation(c->formations[i]);
}
}
int sum_formation_hours(Formation* f, int acc){
acc += f->hours;
Cell* fms = f->formations;
while (fms){
acc += sum_formation_hours(fms, acc);
fms = fms->next;
}
return acc;
}
|