28 lines
575 B
C
28 lines
575 B
C
# 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;
|
|
} |