ajout_liste.c
4.92 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
//By Bianca and Mathis
//Ce programme permet :
//Avec un tableau de char[] donné peut créer une personne et l'ajouter a une liste.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
//Le struct de personne:
typedef struct Personne Personne;
struct Personne {
int athId;
int regId;
int divId;
char* lastName;
char* firstName;
char gender;
int age;
char* weight;
char* height;
int affiliateId;
char* affiliateName;
int overallScrore;
int overallRank;
int score18_1;
char* scoreDisplay18_1;
int rank18_1;
int score18_2;
char* scoreDisplay18_2;
int rank18_2;
int score18_2a;
char* scoreDisplay18_2a;
int rank18_2a;
int score18_3;
char* scoreDisplay18_3;
int rank18_3;
int score18_4;
char* scoreDisplay18_4;
int rank18_4;
int score18_5;
char* scoreDisplay18_5;
int rank18_5;
Personne* suivant;};
typedef Personne* Liste;
/************************************************************************/
//Gestion de listes
void ajout_tete(Liste *l, Personne P)
{
Personne *p;
p= malloc(sizeof(Personne));
p->athId = P.athId;
p->regId = P.regId;
p->divId = P.divId;
p->lastName = P.lastName;
p->firstName = P.firstName;
p->gender = P.gender;
p->age = P.age;
p->weight = P.weight;
p->height = P.height;
p->affiliateId = P.affiliateId;
p->affiliateName = P.affiliateName;
p->overallScrore = P.overallScrore;
p->overallRank = P.overallRank;
p->score18_1 = P.score18_1;
p->scoreDisplay18_1 = P.scoreDisplay18_1;
p->rank18_1 = P.rank18_1;
p->score18_2 = P.score18_2;
p->scoreDisplay18_2 = P.scoreDisplay18_2;
p->rank18_2 = P.rank18_2;
p->score18_2a = P.score18_2a;
p->scoreDisplay18_2a = P.scoreDisplay18_2a;
p->rank18_2a = P.rank18_2a;
p->score18_3 = P.score18_3;
p->scoreDisplay18_3 = P.scoreDisplay18_3;
p->rank18_3 = P.rank18_3;
p->score18_4 = P.score18_4;
p->scoreDisplay18_4 = P.scoreDisplay18_4;
p->rank18_4 = P.rank18_4;
p->score18_5 = P.score18_5;
p->scoreDisplay18_5 = P.scoreDisplay18_5;
p->rank18_5 = P.rank18_5;
p->suivant = *l;
*l=p;
}
void suppr_tete(Liste *l)
{
Personne* a_suppr = *l;
*l = (*l)->suivant;
free(a_suppr);
}
void affiche_personne(Personne P)
{
printf("%s %s %d %c \n", P.lastName, P.firstName, P.overallScrore, P.gender);
}
void affiche_liste(Liste l)
{
Liste tmp = l;
if(tmp==NULL)
{
printf("Liste de personne vide\n");
return;
}
while(tmp != NULL)
{
affiche_personne(*tmp);
tmp = tmp->suivant;
}
printf("\n");
}
/************************************************************************/
void remplissage_personne(char* tab_char[], Personne *P)
{
P->athId = atoi(tab_char[0]);
P->regId = atoi(tab_char[1]);
P->divId = atoi(tab_char[2]);
P->lastName = tab_char[3];
P->firstName = tab_char[4];
P->gender = *tab_char[5];
P->age = atoi(tab_char[6]);
P->weight = tab_char[7];
P->height = tab_char[8];
P->affiliateId = atoi(tab_char[9]);
P->affiliateName = tab_char[10];
P->overallScrore = atoi(tab_char[11]);
P->overallRank = atoi(tab_char[12]);
P->score18_1 = atoi(tab_char[13]);
P->scoreDisplay18_1 = tab_char[14];
P->rank18_1 = atoi(tab_char[15]);
P->score18_2 = atoi(tab_char[16]);
P->scoreDisplay18_2 = tab_char[17];
P->rank18_2 = atoi(tab_char[18]);
P->score18_2a = atoi(tab_char[19]);
P->scoreDisplay18_2a = tab_char[20];
P->rank18_2a = atoi(tab_char[21]);
P->score18_3 = atoi(tab_char[22]);
P->scoreDisplay18_3 = tab_char[23];
P->rank18_3 = atoi(tab_char[24]);
P->score18_4 = atoi(tab_char[25]);
P->scoreDisplay18_4 = tab_char[26];
P->rank18_4 = atoi(tab_char[27]);
P->score18_5 = atoi(tab_char[28]);
P->scoreDisplay18_5 = tab_char[29];
P->rank18_5 = atoi(tab_char[30]);
}
int main(int argc, char * argv[])
{
Personne P;
Liste liste_personne = NULL;
char* tab_char[] = {"584058","11","2","Hoffer","Melanie","F","29","130 lb","66 in","10942","CrossFit Dix Hills","90506","6989","12590000","259 reps","23254","11100195","8:45","37027","11700195","170 lb","11594","13520090","352 reps","7971","11110058","111 reps","6105","11010000","101 reps","4555"};
remplissage_personne(tab_char, &P);
ajout_tete(&liste_personne, P);
tab_char[3] = "Mathis";
tab_char[4] = "Dupre";
remplissage_personne(tab_char, &P);
ajout_tete(&liste_personne, P);
affiche_liste(liste_personne);
printf("Done\n");
return 0;
}