From 61295b44400195e6d35e7dfa4661d3157880a416 Mon Sep 17 00:00:00 2001 From: Vincent Benoist Date: Fri, 12 Jan 2018 09:34:23 +0100 Subject: [PATCH] Tp7Fin --- CtpMemo/Makefile | 17 +++++++++++++++++ Makefile | 17 +++++++++++++++++ Tp6_Matrices/Makefile | 17 +++++++++++++++++ Tp6_Matrices/Tp6_1.o | Bin 0 -> 3608 bytes Tp6_Matrices/Tp6_2.o | Bin 0 -> 4784 bytes Tp7_Struct/.#Donnees | 1 + Tp7_Struct/.Makefile.swo | Bin 0 -> 12288 bytes Tp7_Struct/.Makefile.swp | Bin 0 -> 12288 bytes Tp7_Struct/Donnees | 26 ++++++++++++++++++++++++++ Tp7_Struct/Donnees (copie) | 7 +++++++ Tp7_Struct/Donnees~ | 1 + Tp7_Struct/Makefile | 17 +++++++++++++++++ Tp7_Struct/MakefileNoErr | 17 +++++++++++++++++ Tp7_Struct/Makefile~ | 17 +++++++++++++++++ Tp7_Struct/Tp7.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Tp7_Struct/Tp7.o | Bin 0 -> 3536 bytes Tp7_Struct/prog | Bin 0 -> 13096 bytes 17 files changed, 239 insertions(+), 0 deletions(-) create mode 100644 CtpMemo/Makefile create mode 100644 Makefile create mode 100644 Tp6_Matrices/Makefile create mode 100644 Tp6_Matrices/Tp6_1.o create mode 100644 Tp6_Matrices/Tp6_2.o create mode 120000 Tp7_Struct/.#Donnees create mode 100644 Tp7_Struct/.Makefile.swo create mode 100644 Tp7_Struct/.Makefile.swp create mode 100644 Tp7_Struct/Donnees create mode 100644 Tp7_Struct/Donnees (copie) create mode 100644 Tp7_Struct/Donnees~ create mode 100644 Tp7_Struct/Makefile create mode 100644 Tp7_Struct/MakefileNoErr create mode 100644 Tp7_Struct/Makefile~ create mode 100644 Tp7_Struct/Tp7.c create mode 100644 Tp7_Struct/Tp7.o create mode 100755 Tp7_Struct/prog diff --git a/CtpMemo/Makefile b/CtpMemo/Makefile new file mode 100644 index 0000000..a477689 --- /dev/null +++ b/CtpMemo/Makefile @@ -0,0 +1,17 @@ +.PHONY: clean,real-clean +LD = gcc +CC = gcc +CFLAGS = -Wall -W -Werror +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) +prog : $(OBJ) + $(LD) -o $@ $^ + +%.o : %.c + $(CC) $(CFLAGS) -c $^ + +clean : + rm -f *.o + +real-clean : clean + rm -f prog \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a477689 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: clean,real-clean +LD = gcc +CC = gcc +CFLAGS = -Wall -W -Werror +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) +prog : $(OBJ) + $(LD) -o $@ $^ + +%.o : %.c + $(CC) $(CFLAGS) -c $^ + +clean : + rm -f *.o + +real-clean : clean + rm -f prog \ No newline at end of file diff --git a/Tp6_Matrices/Makefile b/Tp6_Matrices/Makefile new file mode 100644 index 0000000..a477689 --- /dev/null +++ b/Tp6_Matrices/Makefile @@ -0,0 +1,17 @@ +.PHONY: clean,real-clean +LD = gcc +CC = gcc +CFLAGS = -Wall -W -Werror +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) +prog : $(OBJ) + $(LD) -o $@ $^ + +%.o : %.c + $(CC) $(CFLAGS) -c $^ + +clean : + rm -f *.o + +real-clean : clean + rm -f prog \ No newline at end of file diff --git a/Tp6_Matrices/Tp6_1.o b/Tp6_Matrices/Tp6_1.o new file mode 100644 index 0000000..00297d7 Binary files /dev/null and b/Tp6_Matrices/Tp6_1.o differ diff --git a/Tp6_Matrices/Tp6_2.o b/Tp6_Matrices/Tp6_2.o new file mode 100644 index 0000000..d04868f Binary files /dev/null and b/Tp6_Matrices/Tp6_2.o differ diff --git a/Tp7_Struct/.#Donnees b/Tp7_Struct/.#Donnees new file mode 120000 index 0000000..427245f --- /dev/null +++ b/Tp7_Struct/.#Donnees @@ -0,0 +1 @@ +vbenoist@gambrinus05.4868:1515739974 \ No newline at end of file diff --git a/Tp7_Struct/.Makefile.swo b/Tp7_Struct/.Makefile.swo new file mode 100644 index 0000000..615fcdb Binary files /dev/null and b/Tp7_Struct/.Makefile.swo differ diff --git a/Tp7_Struct/.Makefile.swp b/Tp7_Struct/.Makefile.swp new file mode 100644 index 0000000..b1daf72 Binary files /dev/null and b/Tp7_Struct/.Makefile.swp differ diff --git a/Tp7_Struct/Donnees b/Tp7_Struct/Donnees new file mode 100644 index 0000000..e76a11c --- /dev/null +++ b/Tp7_Struct/Donnees @@ -0,0 +1,26 @@ +Benoist +Vincent +24 +10 +1997 +0315978645 +Perreira +Vitine +18 +02 +1992 +0625689715 +Cuvelier +Achile +24 +11 +1997 +0623598614 +Feuille +Luca +10 +01 +1998 ++3306789712346 + + diff --git a/Tp7_Struct/Donnees (copie) b/Tp7_Struct/Donnees (copie) new file mode 100644 index 0000000..3d53cd9 --- /dev/null +++ b/Tp7_Struct/Donnees (copie) @@ -0,0 +1,7 @@ +Benoist +Vincent +24 +10 +1997 +0315978645 + diff --git a/Tp7_Struct/Donnees~ b/Tp7_Struct/Donnees~ new file mode 100644 index 0000000..3b05451 --- /dev/null +++ b/Tp7_Struct/Donnees~ @@ -0,0 +1 @@ +Vincent \ No newline at end of file diff --git a/Tp7_Struct/Makefile b/Tp7_Struct/Makefile new file mode 100644 index 0000000..a477689 --- /dev/null +++ b/Tp7_Struct/Makefile @@ -0,0 +1,17 @@ +.PHONY: clean,real-clean +LD = gcc +CC = gcc +CFLAGS = -Wall -W -Werror +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) +prog : $(OBJ) + $(LD) -o $@ $^ + +%.o : %.c + $(CC) $(CFLAGS) -c $^ + +clean : + rm -f *.o + +real-clean : clean + rm -f prog \ No newline at end of file diff --git a/Tp7_Struct/MakefileNoErr b/Tp7_Struct/MakefileNoErr new file mode 100644 index 0000000..5b66486 --- /dev/null +++ b/Tp7_Struct/MakefileNoErr @@ -0,0 +1,17 @@ +.PHONY: clean,real-clean +LD = gcc +CC = gcc +CFLAGS = -Wall -W +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) +prog : $(OBJ) + $(LD) -o $@ $^ + +%.o : %.c + $(CC) $(CFLAGS) -c $^ + +clean : + rm -f *.o + +real-clean : clean + rm -f prog diff --git a/Tp7_Struct/Makefile~ b/Tp7_Struct/Makefile~ new file mode 100644 index 0000000..a477689 --- /dev/null +++ b/Tp7_Struct/Makefile~ @@ -0,0 +1,17 @@ +.PHONY: clean,real-clean +LD = gcc +CC = gcc +CFLAGS = -Wall -W -Werror +SRC=$(wildcard *.c) +OBJ=$(SRC:.c=.o) +prog : $(OBJ) + $(LD) -o $@ $^ + +%.o : %.c + $(CC) $(CFLAGS) -c $^ + +clean : + rm -f *.o + +real-clean : clean + rm -f prog \ No newline at end of file diff --git a/Tp7_Struct/Tp7.c b/Tp7_Struct/Tp7.c new file mode 100644 index 0000000..c6b3616 --- /dev/null +++ b/Tp7_Struct/Tp7.c @@ -0,0 +1,102 @@ +#include +#include + +#define ContigueLength 512 +#define NbChar 32 + +typedef struct{ + int jour, mois,annee; +}Date; + +typedef struct{ + char nom[NbChar], prenom[NbChar], tel[NbChar]; + Date date; +}Personne; + +typedef struct{ + Personne listePers[ContigueLength]; + int dernier; +}Annuaire; + + +void lireDate(Date *date){ + scanf("%d%d%d",&date->jour,&date->mois, &date->annee); +} + +void afficheDate(Date date){ + printf("Jour: %d | Mois: %d | Annee: %d\n",date.jour, date.mois, date.annee); +} + +int lirePersonne(Personne *pers){ + if(scanf("%s",pers->nom)!=EOF){ + scanf("%s",pers->prenom); + lireDate(&pers->date); + scanf("%s",pers->tel); + return 1; + }else { + return 0; + } + +//if(scanf("%s")==EOF); + +} + +void affichePers(Personne p){ + printf("Nom: %s | Prenom: %s | Tel: %s\n",p.nom, p.prenom, p.tel); + afficheDate(p.date); +} + +void creerAnnuaire(Annuaire *annuaire){ + annuaire->dernier=-1; + //tq lecture d'une nouvelle personne est possible -> ajoute pers et +1 à annuaire.dernier + while((annuaire->dernier < ContigueLength) && (lirePersonne(&annuaire->listePers[(annuaire->dernier)+1])!=0)){ + annuaire->dernier+=1; + } +} + +void afficheAnnuaire(Annuaire annuaire){ + int i; + for(i = 0; i <= annuaire.dernier; i++){ + affichePers(annuaire.listePers[i]); + + } +} + +int compareDate(Date d1, Date d2){ + if(d1.annee == d2.annee){ + if(d1.mois == d2.mois){ + if(d1.jour == d2.jour){ + return 0; + }else if(d1.jour < d2.jour){ + return -1; + } + + }else if(d1.mois < d2.mois){ + return -1; + } + + }else if(d1.annee < d2.annee){ + return -1; + } + return 1; + +} + + +int main(){ + + /* Date d; + lireDate( &d); + afficheDate(d); + Personne p; + lirePersonne(&p); + affichePers(p);*/ + + Annuaire annuaire; + creerAnnuaire(&annuaire); + afficheAnnuaire(annuaire); + return 1; +} + + + diff --git a/Tp7_Struct/Tp7.o b/Tp7_Struct/Tp7.o new file mode 100644 index 0000000..714d5d7 Binary files /dev/null and b/Tp7_Struct/Tp7.o differ diff --git a/Tp7_Struct/prog b/Tp7_Struct/prog new file mode 100755 index 0000000..4c93192 Binary files /dev/null and b/Tp7_Struct/prog differ -- libgit2 0.21.2