Commit 61295b44400195e6d35e7dfa4661d3157880a416
1 parent
5eb7fe63
Tp7Fin
Showing
17 changed files
with
239 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +.PHONY: clean,real-clean | ||
2 | +LD = gcc | ||
3 | +CC = gcc | ||
4 | +CFLAGS = -Wall -W -Werror | ||
5 | +SRC=$(wildcard *.c) | ||
6 | +OBJ=$(SRC:.c=.o) | ||
7 | +prog : $(OBJ) | ||
8 | + $(LD) -o $@ $^ | ||
9 | + | ||
10 | +%.o : %.c | ||
11 | + $(CC) $(CFLAGS) -c $^ | ||
12 | + | ||
13 | +clean : | ||
14 | + rm -f *.o | ||
15 | + | ||
16 | +real-clean : clean | ||
17 | + rm -f prog | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +.PHONY: clean,real-clean | ||
2 | +LD = gcc | ||
3 | +CC = gcc | ||
4 | +CFLAGS = -Wall -W -Werror | ||
5 | +SRC=$(wildcard *.c) | ||
6 | +OBJ=$(SRC:.c=.o) | ||
7 | +prog : $(OBJ) | ||
8 | + $(LD) -o $@ $^ | ||
9 | + | ||
10 | +%.o : %.c | ||
11 | + $(CC) $(CFLAGS) -c $^ | ||
12 | + | ||
13 | +clean : | ||
14 | + rm -f *.o | ||
15 | + | ||
16 | +real-clean : clean | ||
17 | + rm -f prog | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +.PHONY: clean,real-clean | ||
2 | +LD = gcc | ||
3 | +CC = gcc | ||
4 | +CFLAGS = -Wall -W -Werror | ||
5 | +SRC=$(wildcard *.c) | ||
6 | +OBJ=$(SRC:.c=.o) | ||
7 | +prog : $(OBJ) | ||
8 | + $(LD) -o $@ $^ | ||
9 | + | ||
10 | +%.o : %.c | ||
11 | + $(CC) $(CFLAGS) -c $^ | ||
12 | + | ||
13 | +clean : | ||
14 | + rm -f *.o | ||
15 | + | ||
16 | +real-clean : clean | ||
17 | + rm -f prog | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +.PHONY: clean,real-clean | ||
2 | +LD = gcc | ||
3 | +CC = gcc | ||
4 | +CFLAGS = -Wall -W -Werror | ||
5 | +SRC=$(wildcard *.c) | ||
6 | +OBJ=$(SRC:.c=.o) | ||
7 | +prog : $(OBJ) | ||
8 | + $(LD) -o $@ $^ | ||
9 | + | ||
10 | +%.o : %.c | ||
11 | + $(CC) $(CFLAGS) -c $^ | ||
12 | + | ||
13 | +clean : | ||
14 | + rm -f *.o | ||
15 | + | ||
16 | +real-clean : clean | ||
17 | + rm -f prog | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +.PHONY: clean,real-clean | ||
2 | +LD = gcc | ||
3 | +CC = gcc | ||
4 | +CFLAGS = -Wall -W | ||
5 | +SRC=$(wildcard *.c) | ||
6 | +OBJ=$(SRC:.c=.o) | ||
7 | +prog : $(OBJ) | ||
8 | + $(LD) -o $@ $^ | ||
9 | + | ||
10 | +%.o : %.c | ||
11 | + $(CC) $(CFLAGS) -c $^ | ||
12 | + | ||
13 | +clean : | ||
14 | + rm -f *.o | ||
15 | + | ||
16 | +real-clean : clean | ||
17 | + rm -f prog |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +.PHONY: clean,real-clean | ||
2 | +LD = gcc | ||
3 | +CC = gcc | ||
4 | +CFLAGS = -Wall -W -Werror | ||
5 | +SRC=$(wildcard *.c) | ||
6 | +OBJ=$(SRC:.c=.o) | ||
7 | +prog : $(OBJ) | ||
8 | + $(LD) -o $@ $^ | ||
9 | + | ||
10 | +%.o : %.c | ||
11 | + $(CC) $(CFLAGS) -c $^ | ||
12 | + | ||
13 | +clean : | ||
14 | + rm -f *.o | ||
15 | + | ||
16 | +real-clean : clean | ||
17 | + rm -f prog | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
@@ -0,0 +1,102 @@ | @@ -0,0 +1,102 @@ | ||
1 | +#include <stdio.h> | ||
2 | +#include <string.h> | ||
3 | + | ||
4 | +#define ContigueLength 512 | ||
5 | +#define NbChar 32 | ||
6 | + | ||
7 | +typedef struct{ | ||
8 | + int jour, mois,annee; | ||
9 | +}Date; | ||
10 | + | ||
11 | +typedef struct{ | ||
12 | + char nom[NbChar], prenom[NbChar], tel[NbChar]; | ||
13 | + Date date; | ||
14 | +}Personne; | ||
15 | + | ||
16 | +typedef struct{ | ||
17 | + Personne listePers[ContigueLength]; | ||
18 | + int dernier; | ||
19 | +}Annuaire; | ||
20 | + | ||
21 | + | ||
22 | +void lireDate(Date *date){ | ||
23 | + scanf("%d%d%d",&date->jour,&date->mois, &date->annee); | ||
24 | +} | ||
25 | + | ||
26 | +void afficheDate(Date date){ | ||
27 | + printf("Jour: %d | Mois: %d | Annee: %d\n",date.jour, date.mois, date.annee); | ||
28 | +} | ||
29 | + | ||
30 | +int lirePersonne(Personne *pers){ | ||
31 | + if(scanf("%s",pers->nom)!=EOF){ | ||
32 | + scanf("%s",pers->prenom); | ||
33 | + lireDate(&pers->date); | ||
34 | + scanf("%s",pers->tel); | ||
35 | + return 1; | ||
36 | + }else { | ||
37 | + return 0; | ||
38 | + } | ||
39 | + | ||
40 | +//if(scanf("%s")==EOF); | ||
41 | + | ||
42 | +} | ||
43 | + | ||
44 | +void affichePers(Personne p){ | ||
45 | + printf("Nom: %s | Prenom: %s | Tel: %s\n",p.nom, p.prenom, p.tel); | ||
46 | + afficheDate(p.date); | ||
47 | +} | ||
48 | + | ||
49 | +void creerAnnuaire(Annuaire *annuaire){ | ||
50 | + annuaire->dernier=-1; | ||
51 | + //tq lecture d'une nouvelle personne est possible -> ajoute pers et +1 à annuaire.dernier | ||
52 | + while((annuaire->dernier < ContigueLength) && (lirePersonne(&annuaire->listePers[(annuaire->dernier)+1])!=0)){ | ||
53 | + annuaire->dernier+=1; | ||
54 | + } | ||
55 | +} | ||
56 | + | ||
57 | +void afficheAnnuaire(Annuaire annuaire){ | ||
58 | + int i; | ||
59 | + for(i = 0; i <= annuaire.dernier; i++){ | ||
60 | + affichePers(annuaire.listePers[i]); | ||
61 | + | ||
62 | + } | ||
63 | +} | ||
64 | + | ||
65 | +int compareDate(Date d1, Date d2){ | ||
66 | + if(d1.annee == d2.annee){ | ||
67 | + if(d1.mois == d2.mois){ | ||
68 | + if(d1.jour == d2.jour){ | ||
69 | + return 0; | ||
70 | + }else if(d1.jour < d2.jour){ | ||
71 | + return -1; | ||
72 | + } | ||
73 | + | ||
74 | + }else if(d1.mois < d2.mois){ | ||
75 | + return -1; | ||
76 | + } | ||
77 | + | ||
78 | + }else if(d1.annee < d2.annee){ | ||
79 | + return -1; | ||
80 | + } | ||
81 | + return 1; | ||
82 | + | ||
83 | +} | ||
84 | + | ||
85 | + | ||
86 | +int main(){ | ||
87 | + | ||
88 | + /* Date d; | ||
89 | + lireDate( &d); | ||
90 | + afficheDate(d); | ||
91 | + Personne p; | ||
92 | + lirePersonne(&p); | ||
93 | + affichePers(p);*/ | ||
94 | + | ||
95 | + Annuaire annuaire; | ||
96 | + creerAnnuaire(&annuaire); | ||
97 | + afficheAnnuaire(annuaire); | ||
98 | + return 1; | ||
99 | +} | ||
100 | + | ||
101 | + | ||
102 | + |
No preview for this file type
No preview for this file type