diff --git a/DEV1.1/TP19/complexe b/DEV1.1/TP19/complexe new file mode 100755 index 0000000..25de9b0 Binary files /dev/null and b/DEV1.1/TP19/complexe differ diff --git a/DEV1.1/TP19/complexe.c b/DEV1.1/TP19/complexe.c new file mode 100644 index 0000000..ac4e934 --- /dev/null +++ b/DEV1.1/TP19/complexe.c @@ -0,0 +1,49 @@ +#include +#include +#include + +struct nbrcomplex{ + float x; + float y; +}; + +typedef struct nbrcomplex complex; + +void afficher(complex z){ + printf("%f + %fi\n",z.x,z.y); +} + +float module(complex z){ + float res=sqrt(pow(z.x,2)+pow(z.y,2)); + float resrac=pow(res,0.5); + return resrac; +} + +complex inverse(complex z){ + complex a; + a.x = z.x/pow(module(z),2); + a.y =z.y/pow(module(z),2); + return a; +} + +complex conjugue(complex z){ + complex b; + b.x = z.x; + b.y =-z.y; + return b; +} + +int main(int argc,char const* argv[]) { + complex z={3,8}; + complex a, b, c; + afficher(z); + a=z; + module(a); + printf("|z|=%f\n",a); + b=conjugue(z); + afficher(b); + printf("conjugue=%f\n",b); + c=inverse(z); + afficher(c); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP20/challenger b/DEV1.1/TP20/challenger new file mode 100755 index 0000000..4973ef8 Binary files /dev/null and b/DEV1.1/TP20/challenger differ diff --git a/DEV1.1/TP20/challenger.c b/DEV1.1/TP20/challenger.c new file mode 100644 index 0000000..96c5ae1 --- /dev/null +++ b/DEV1.1/TP20/challenger.c @@ -0,0 +1,25 @@ +#include +#include + +int main(int argc, char** argv){ + int score,score_prec,i,chal_score; + char nom[3]; + chal_score=strtol(argv[1],NULL,10); + FILE* file; + file=fopen("top10","r"); + if (file==NULL){ + printf("mauvaise ouverture"); + return EXIT_FAILURE; + } + printf("|Hall of Fame|\n"); + for (i=0;i<10;i++){ + fread(&score,sizeof(int),1,file); + fread(nom,sizeof(char),3,file); + if (chal_score>score && chal_score +#include + +int main(void){ + int score,i; + char nom[3]; + FILE* file; + file=fopen("top10","r"); + if (file==NULL){ + printf("mauvaise ouverture"); + return EXIT_FAILURE; + } + printf("|Hall of Fame|\n"); + for (i=0;i<10;i++){ + fread(&score,4,1,file); + fread(&nom,3,1,file); + printf("%09d %s\n",score,nom); + } + fclose(file); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP20/top10 b/DEV1.1/TP20/top10 new file mode 100644 index 0000000..f6c571a Binary files /dev/null and b/DEV1.1/TP20/top10 differ diff --git a/DEV1.1/TP21/compte b/DEV1.1/TP21/compte new file mode 100644 index 0000000..f16a710 Binary files /dev/null and b/DEV1.1/TP21/compte differ diff --git a/DEV1.1/TP21/compteur b/DEV1.1/TP21/compteur new file mode 100755 index 0000000..7a78586 Binary files /dev/null and b/DEV1.1/TP21/compteur differ diff --git a/DEV1.1/TP21/compteur.c b/DEV1.1/TP21/compteur.c new file mode 100644 index 0000000..16f912e --- /dev/null +++ b/DEV1.1/TP21/compteur.c @@ -0,0 +1,24 @@ +#include +#include + +int main(void){ + int compteur; + FILE* file; + file=fopen("compte","r"); + if (file==NULL){ + printf("mauvaise ouverture"); + return EXIT_FAILURE; + } + fread(&compteur,sizeof(int),1,file); + printf("%d\n",compteur); + fclose(file); + fopen("compte","w"); + if (file==NULL){ + printf("mauvaise ouverture"); + return EXIT_FAILURE; + } + compteur++; + fwrite(&compteur,sizeof(int),1,file); + fclose(file); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP21/compteur.txt b/DEV1.1/TP21/compteur.txt new file mode 100644 index 0000000..31ea9d1 Binary files /dev/null and b/DEV1.1/TP21/compteur.txt differ diff --git a/DEV1.1/TP21/init b/DEV1.1/TP21/init new file mode 100755 index 0000000..88dfc0d Binary files /dev/null and b/DEV1.1/TP21/init differ diff --git a/DEV1.1/TP21/init.c b/DEV1.1/TP21/init.c new file mode 100644 index 0000000..1165714 --- /dev/null +++ b/DEV1.1/TP21/init.c @@ -0,0 +1,11 @@ +#include +#include + +int main(void){ + int depart=0; + FILE* file; + file=fopen("compte","w"); + fwrite(&depart,sizeof(int),1,file); + fclose(file); + return EXIT_SUCCESS; +} \ No newline at end of file