/* Creation de liste chainée circulaire avec n cellules */ #include #include typedef struct cell cell; struct cell { int n; struct cell * s; struct cell * p; } void creerliste(cell * debut) { int n = 4, i; cell * oldcell; cell * newcell; debut = malloc(sizeof (cell)); debut->n = 1; debut->s = debut; debut->p = debut; oldcell = debut; for(i = 2; i <= n; i++) { newcell = malloc(sizeof *newcell); printf("%d ", newcell->n = i); newcell->s = debut; newcell->p = oldcell; oldcell->s = newcell; debut->p = newcell; oldcell = newcell; } putchar('\n'); } cell * d; int main() { creerliste(d); return 0; }