From 93ffb9240ad68942873939303a7889f9b1dfd030 Mon Sep 17 00:00:00 2001 From: Simon Saye Babu Date: Tue, 22 Nov 2022 11:26:37 +0100 Subject: [PATCH] tp ou jai lu le debut de killing stalking --- DEV1.1/TD/TD10.c | 98 ++++++++++++++++++++++++++++++++++ DEV1.1/TD/TD10.txt | 0 DEV1.1/TP11/complexes.c | 32 +++++++++++ DEV1.1/TP11/date.c | 13 +++++ DEV1.1/TP11/groupe.c | 38 +++++++++++++ DEV1.1/TP11/tailles.c | 17 ++++++ DEV1.1/TP12/exo1.tar.gz | Bin 0 -> 2025 bytes DEV1.1/TP12/exo1/Makefile | 41 ++++++++++++++ DEV1.1/TP12/exo1/exo1 | Bin 0 -> 26616 bytes DEV1.1/TP12/exo1/lire.h | 8 +++ DEV1.1/TP12/exo1/lire.s | 30 +++++++++++ DEV1.1/TP12/exo1/main.c | 42 +++++++++++++++ DEV1.1/TP12/exo1/personne.c | 33 ++++++++++++ DEV1.1/TP12/exo1/personne.h | 16 ++++++ DEV1.1/TP12/exo1/repertoire.c | 38 +++++++++++++ DEV1.1/TP12/exo1/repertoire.h | 20 +++++++ DEV1.1/TP12/texte.txt | 20 +++++++ 17 files changed, 446 insertions(+) create mode 100644 DEV1.1/TD/TD10.c create mode 100644 DEV1.1/TD/TD10.txt create mode 100644 DEV1.1/TP11/complexes.c create mode 100644 DEV1.1/TP11/date.c create mode 100644 DEV1.1/TP11/groupe.c create mode 100644 DEV1.1/TP11/tailles.c create mode 100644 DEV1.1/TP12/exo1.tar.gz create mode 100644 DEV1.1/TP12/exo1/Makefile create mode 100755 DEV1.1/TP12/exo1/exo1 create mode 100644 DEV1.1/TP12/exo1/lire.h create mode 100644 DEV1.1/TP12/exo1/lire.s create mode 100644 DEV1.1/TP12/exo1/main.c create mode 100644 DEV1.1/TP12/exo1/personne.c create mode 100644 DEV1.1/TP12/exo1/personne.h create mode 100644 DEV1.1/TP12/exo1/repertoire.c create mode 100644 DEV1.1/TP12/exo1/repertoire.h create mode 100644 DEV1.1/TP12/texte.txt diff --git a/DEV1.1/TD/TD10.c b/DEV1.1/TD/TD10.c new file mode 100644 index 0000000..1d8fc2f --- /dev/null +++ b/DEV1.1/TD/TD10.c @@ -0,0 +1,98 @@ +#include +#include +#include + +struct blob{ + char faction; + int taille; +}; + +typedef struct blob blob; + +struct arene{ + blob combattant[50]; +}; + +typedef struct arene arene; + +void printBlob(blob b) { + printf("Faction : %c\nTaille : %d\n",b.faction, b.taille); +} + +blob rencontre(blob blob1,blob blob2) { + int tailleOut; + char factionOut; + if (blob1.faction==blob2.faction) + { + tailleOut = blob1.taille + blob2.taille; + factionOut = blob1.faction; + } + if (blob1.faction!=blob2.faction) + { + if (blob1.taille>blob2.taille) + { + tailleOut = blob1.taille-blob2.taille; + factionOut = blob1.faction; + } + if (blob1.taille +#include +#include + +struct complexe{ + double x; + double y; +}; + +int module(struct complexe cp){ + return sqrt(pow(cp.x,2)+pow(cp.y,2)); +} + +void inverse(struct complexe cp){ + printf("%d + I * %d\n",cp.x/pow(module(cp),2),cp.y/pow(module(cp),2)); +} + +void conjugue(struct complexe cp){ + printf("%d - %d * I\n", cp.x, cp.y); +} + +int main(int argc, char const *argv[]) +{ + struct complexe lol={2.785,5.233}; + double lolol=module(lol); + printf("%d \n",lolol); + conjugue(lol); + inverse(lol); + + + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP11/date.c b/DEV1.1/TP11/date.c new file mode 100644 index 0000000..131c65e --- /dev/null +++ b/DEV1.1/TP11/date.c @@ -0,0 +1,13 @@ +#include +#include +#include + + + +int main(int argc, char const *argv[]) +{ + time_t timestamp = time(NULL); + struct tm * timeInfos = localtime(& timestamp); + printf("%04d/%02d/%02d\n", timeInfos->tm_year+1900, timeInfos->tm_mon+1,timeInfos->tm_mday); + return 0; +} diff --git a/DEV1.1/TP11/groupe.c b/DEV1.1/TP11/groupe.c new file mode 100644 index 0000000..13c67b7 --- /dev/null +++ b/DEV1.1/TP11/groupe.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +int main(int argc, char const *argv[]) +{ + struct group *grp; + + char grpname[]="senart22", **curr; + /* + if ((grp= getgrnam(grpname))== NULL) + printf("pas de groupe a ce nom"); + else + { + printf("Membre du groupe %s : \n", grpname); + for (curr=grp->gr_mem; (*curr) != NULL; curr++) + printf(" %s\n", *curr); + }*/ + + struct group etu; + etu=*getgrname("senart22"); + + int i=0; + while(*etu.gr_name[i]!=NULL) + { + for (int j = 0; j < sizeof(etu.gr_name[i]); ++j) + { + printf("%s",etu.gr_name[i][j]); + } + printf("\n"); + } + + + + + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP11/tailles.c b/DEV1.1/TP11/tailles.c new file mode 100644 index 0000000..de519f7 --- /dev/null +++ b/DEV1.1/TP11/tailles.c @@ -0,0 +1,17 @@ +#include +#include + +struct blablabla{ + int a; + char b; + char c; +}; + +typedef struct blablabla abc; + +int main(int argc, char const *argv[]) +{ + abc blabla={50,'a','c'}; + printf("%d \n", sizeof(blabla) ); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP12/exo1.tar.gz b/DEV1.1/TP12/exo1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..e301fdcde16d356263ab157f89be59bcc4eda9d8 GIT binary patch literal 2025 zcmV(K zd9Yikh+e0|ezjgl zE&paX&~!~x+bvz!^aE8>dusatIy?4@V-dwB1vs#Y??#X4Z7ctqg0T7bTuPd|>l~Zl zZnwK>{7Cx^hv-cCZd3O3%J&~nU({kKvHokF411pn;i)j9<^qk&=6+N3c z*Op^m2aXew7_@GsG?jMi&?rjog5Q{-D6GRqbCle=QA{Xw<-7;?0sR$g*!Ok*H*v}wv69ZMXeQdBXIcd81zf6mo#;zsnVz?{2CKshD?V9w;SD^~R5l+9 z>v__ZI%u`TCl@XYpMLg}1#_(}yNN@Y6r8Yb-tca&+ABGZUgrxb2sf`I=+)t$Spg++ zMTht{Uy-<6jnZcl&<63hUIkQ+8aQsr1k6g#c@PZ3tGCd!Ujq4B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,0 +1,41 @@ +# TP 19 Exercice 1 : fichier Makefile + +# CHAPITRE 1 : BUT FINAL + +but : exo1 + +# CHAPITRE 2 : VARIABLES + +OFILES = lire.o \ + personne.o \ + repertoire.o \ + main.o + +CC = gcc + +CFLAGS = -Wall -ansi -pedantic -g + +# CHAPITRE 3 : DEPENDANCES (REGLES IMPLICITES) + +personne.o : personne.h lire.h + +repertoire.o : repertoire.h personne.h + +main.o : personne.h repertoire.h + +#CHAPITRE 4 : DEPENDANCES AVEC COMMANDES + +lire.o : lire.s lire.h + as -o lire.o lire.s + +exo1 : $(OFILES) + $(CC) $(CFLAGS) -o exo1 $(OFILES) + +#CHAPITRE 5 : NETTOYAGE DES FICHIERS GENERES + +clean : + -rm -f $(OFILES) exo1 + +#CHAPITRE 6 : BUTS FACTICES + +.PHONY : but clean diff --git a/DEV1.1/TP12/exo1/exo1 b/DEV1.1/TP12/exo1/exo1 new file mode 100755 index 0000000000000000000000000000000000000000..6b77f519694aef09095b36ee969393a2f885a924 GIT binary patch literal 26616 zcmeHw3vgW3ndZ5-`}RXEwOW?^ezm|h1|rFl!4JS#e#o?pU)VB%Y)I4YZb?0~xge9SZCh;166WxT>jg`XL=>f0Gamhb zMgV%n8qtL7Qn5t%Q1(ii;`b^5t~yTHwJ@OR9zg2NAuoGRZb}0F0*VV#9Ixa^wGR5GE zXEEQ|BVC|hD{wMxZrHI`*oVXk(u}?(teUc2SEg(mPKKTO$L_v$Zt#&O8dpDeXz$ql z#ee&~f46X$GHeHJQicaa|C8f7kD_<*^ESiI<11j>wysK}!!=zj@% zbP{>iKbalo*<|#lDd@LOK|cX{6leX>4Z>vhFP(yZ`xNy526_}{{jn84C()Y#R25M)EoB zM_h?cDu`y=$X*Lq8ySiGmYAcV1zH|5=02RA$)L*}aZuCRWZ5gmbor~tK8E!5h$FgO zo|g%-h6hpRVa87r=Z9Mq{gfUb4SkoU$9fgt&`tTodPV2GqHldkc&du7heAnzwu)|S zk#VYu-Y6y2<#ZLDIc^S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,0 +1,8 @@ +/* TP 19 Exercice 1 : fichier lire.h */ + +#ifndef LIRE_H +#define LIRE_H + +void lire(char*, int); + +#endif /* LIRE_H */ diff --git a/DEV1.1/TP12/exo1/lire.s b/DEV1.1/TP12/exo1/lire.s new file mode 100644 index 0000000..d4f5f35 --- /dev/null +++ b/DEV1.1/TP12/exo1/lire.s @@ -0,0 +1,30 @@ + .section .text + .globl lire + .type lire, @function +lire: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + + xorq %rdx, %rdx + movl %esi, %edx # taille max + movq %rdi, %rsi # adresse chaine + movq $0, %rax # read + movq $0, %rdi # stdin + decq %rdx # place du \0 + syscall # call read + cmpb $10, -1(%rsi, %rax, 1) # si \n + jne lire_1 + decq %rax +lire_1: movb $0, (%rsi, %rax, 1) # place \0 + + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size lire, .-lire diff --git a/DEV1.1/TP12/exo1/main.c b/DEV1.1/TP12/exo1/main.c new file mode 100644 index 0000000..e182a76 --- /dev/null +++ b/DEV1.1/TP12/exo1/main.c @@ -0,0 +1,42 @@ +/* TP19 Exercice 1 : fichier main.c */ + +#include +#include +#include "personne.h" +#include "repertoire.h" + +typedef enum {AJOUTER, AFFICHER, SORTIR} options; + +options saisir_option() { + short o; + printf("\nChoisissez une option :\n"); + printf("1] Ajouter une personne.\n"); + printf("2] Afficher le repertoire.\n"); + printf("3] Sortir\n"); + printf("? "); + scanf("%hd", &o); + switch(o) { + case 1 : return AJOUTER; + case 2 : return AFFICHER; + case 3 : return SORTIR; + default : return AFFICHER; + } +} + +int main(void) { + options opt; + repertoire r = construire_repertoire(); + while ((opt=saisir_option())!=SORTIR) + switch(opt) { + case AJOUTER : + ajouter_personne(r, saisir_personne()); + break; + case AFFICHER : + afficher_repertoire(r); + break; + default : + ; /* rien a faire */ + } + detruire_repertoire(r); + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP12/exo1/personne.c b/DEV1.1/TP12/exo1/personne.c new file mode 100644 index 0000000..38195d8 --- /dev/null +++ b/DEV1.1/TP12/exo1/personne.c @@ -0,0 +1,33 @@ +/* TP 19 Exercice 1 : fichier personne.c */ + +#include +#include +#include +#include "personne.h" +#include "lire.h" + +personne construire_personne(const char *nom, const char *tel) { + personne p = (personne) malloc(sizeof(struct s_personne)); + strcpy(p->nom, nom); + strcpy(p->tel, tel); + return p; +} + +personne saisir_personne() { + personne p = (personne) malloc(sizeof(struct s_personne)); + printf("\nEntrez le nom de la personne : "); + fflush(stdout); + lire(p->nom, 30); + printf("Entrez son numero de telephone : "); + fflush(stdout); + lire(p->tel, 20); + return p; +} + +void afficher_personne(personne p) { + printf("%-30s %-20s\n", p->nom, p->tel); +} + +void detruire_personne(personne p) { + free(p); +} diff --git a/DEV1.1/TP12/exo1/personne.h b/DEV1.1/TP12/exo1/personne.h new file mode 100644 index 0000000..079ef3e --- /dev/null +++ b/DEV1.1/TP12/exo1/personne.h @@ -0,0 +1,16 @@ +/* TP 19 Exercice 1 : fichier personne.h */ + +#ifndef PERSONNE_H +#define PERSONNE_H + +typedef struct s_personne { + char nom[30]; + char tel[20]; +} * personne; + +personne construire_personne(const char*, const char*); +personne saisir_personne(); +void afficher_personne(personne); +void detruire_personne(personne); + +#endif /* PERSONNE_H */ diff --git a/DEV1.1/TP12/exo1/repertoire.c b/DEV1.1/TP12/exo1/repertoire.c new file mode 100644 index 0000000..9964f2c --- /dev/null +++ b/DEV1.1/TP12/exo1/repertoire.c @@ -0,0 +1,38 @@ +/* TP 19 Exercice 1 : fichier repertoire.c */ + +#include +#include +#include "repertoire.h" +#include "lire.h" + +repertoire construire_repertoire() { + repertoire r = (repertoire) malloc(sizeof(struct s_repertoire)); + r->taille = 0; + return r; +} + +void afficher_repertoire(repertoire r) { + int i = 0; + printf("\n%-30s %-20s\n", "Nom", "Telephone"); + for(; itaille; i++) + afficher_personne((r->personnes)[i]); +} + +int ajouter_personne(repertoire r, personne p) { + if (r->taillepersonnes)[r->taille] = p; + (r->taille)++; + return 0; + } else + return 1; +} + +void detruire_repertoire(repertoire r) { + int i = r->taille; + while(i-->0) { + free((r->personnes)[i]); + } + free(r); +} + + diff --git a/DEV1.1/TP12/exo1/repertoire.h b/DEV1.1/TP12/exo1/repertoire.h new file mode 100644 index 0000000..f6db222 --- /dev/null +++ b/DEV1.1/TP12/exo1/repertoire.h @@ -0,0 +1,20 @@ +/* TP 19 Exercice 1 : fichier repertoire.h */ + +#ifndef REPERTOIRE_H +#define REPERTOIRE_H + +#include "personne.h" + +#define CAPACITE 100 + +typedef struct s_repertoire { + int taille; + personne personnes[CAPACITE]; +} * repertoire; + +repertoire construire_repertoire(); +void afficher_repertoire(repertoire); +int ajouter_personne(repertoire, personne); +void detruire_repertoire(repertoire); + +#endif /* REPERTOIRE_H */ diff --git a/DEV1.1/TP12/texte.txt b/DEV1.1/TP12/texte.txt new file mode 100644 index 0000000..1e26832 --- /dev/null +++ b/DEV1.1/TP12/texte.txt @@ -0,0 +1,20 @@ +1. des fonctions + + + +as -o lire.o lire.s +gcc -Wall -ansi -pedantic -g -c -o personne.o personne.c +gcc -Wall -ansi -pedantic -g -c -o repertoire.o repertoire.c +gcc -Wall -ansi -pedantic -g -c -o main.o main.c +gcc -Wall -ansi -pedantic -g -o exo1 lire.o personne.o repertoire.o main.o + + +non + +il a rien fait + +il execute que les commande ou repertoire est mentionnée + +main.o: main.c personne.h repertoire.h + +les dependance ??? \ No newline at end of file