Entrainements + fin TP structures

This commit is contained in:
Simoes Lukas
2024-12-02 14:12:49 +01:00
parent 161df92584
commit 6f3e79de9d
36 changed files with 1240 additions and 0 deletions

View File

28
DEV1.1/TP25/test.c Normal file
View File

@@ -0,0 +1,28 @@
# include <stdio.h>
# include <stdlib.h>
struct maillon {
int valeur;
struct maillon* suivant;
};
void creation_liste(struct maillon* liste) {
int i;
liste->valeur = (rand() % 888) + 111;
for (i = 0; i != 10; i++) {
struct maillon* prochain = (struct maillon*) malloc(sizeof(struct maillon*));
if (prochain == NULL) {
printf("Erreur d'allocation mémoire.\n");
}
prochain->valeur = (rand() % 888) + 111;
liste->suivant = prochain;
}
}
int main(void) {
struct maillon* liste = NULL;
srand(time(NULL));
creation_liste(liste);
return EXIT_SUCCESS;
}