Est ce que c'est possible d'utiliser des listes chainées pour ajouter un objet ayant un abscisse x, une ordonnée y et un corps c?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 #ifndef MABIB #define MABIB #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct point{ char c; int x; int y; } s_point; typedef struct s_maillon { void *donnees; struct s_maillon *suiv; }MAILLON; /*typedef struct s_maillon { char c; int x; int y; struct s_maillon *suiv; }MAILLON;*/ MAILLON *allouerMaillon(void *donnee) { MAILLON *maillon=NULL; maillon=(MAILLON*)malloc(sizeof(MAILLON)); if(maillon) { maillon->donnees=donnee; maillon->suiv=NULL; } return maillon; } void insertion_tete(MAILLON **ancre,void *donnee) { MAILLON *ancien=*ancre; MAILLON *nouveau= NULL; nouveau= allouerMaillon(donnee); nouveau->suiv=ancien; *ancre=nouveau; } void *suppression_tete(MAILLON **ancre) { MAILLON *maillon=*ancre; void *resultat=NULL; if(maillon) { resultat=maillon->donnees; *ancre=maillon->suiv; free(malloc); } } void *suppression_queue(MAILLON **ancre) { MAILLON *maillon=*ancre; void *resultat=NULL; if(maillon) { resultat=suppression_tete(ancre); } else { resultat=suppression_queue(&(maillon->suiv)); } return resultat; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include "MABIBliste.h" int main(int argc, char *argv[]) { MAILLON *ancre=NULL; s_point missile; missile.x=5; missile.y=10; missile.c='-'; s_point *p; p=&missile; insertion_tete(ancre,missile); system("PAUSE"); return 0; }
Partager