From 094a8ed4b14a4ab1c1d6644ffc82f92648831890 Mon Sep 17 00:00:00 2001 From: moogin Date: Tue, 15 Oct 2024 12:29:56 +0200 Subject: [PATCH] rattrapage jusqu'a adresse --- DEV1.1/biblio_math.c | 62 ++++++++++++++++ DEV1.1/tableaux.c | 60 ++++++++++++++++ DEV1.1/tableaux_multi.c | 153 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+) create mode 100644 DEV1.1/biblio_math.c create mode 100644 DEV1.1/tableaux_multi.c diff --git a/DEV1.1/biblio_math.c b/DEV1.1/biblio_math.c new file mode 100644 index 0000000..faea26d --- /dev/null +++ b/DEV1.1/biblio_math.c @@ -0,0 +1,62 @@ +#include +#include +#include + +int main (void){ + double x,y,z,a,b,c; + x= sqrt(fabs(log(0.5))); + y=sin(M_PI/6); + z=atan(pow(13.0,2.0)); + a=pow(exp(-1.0),4.0); + b=log(-3); + c=pow(sqrt(2),2); + + printf("%.2f\n",x); + printf("%.2f\n",y); + printf("%.2f\n",z); + printf("%.2f\n",a); + printf("%.2f\n",b); + printf("%.2f\n",c); + return EXIT_SUCCESS; +} + + +int main (void){ + double ax,bx,ay,by,distance; + printf("Les coordonnées du point A en X et en Y : \n"); + scanf("%lf", &ax); + scanf("%lf", &ay); + printf("Les coordonnées du point B en X et en Y : \n"); + scanf("%lf", &bx); + scanf("%lf", &by); + distance = sqrt(pow((bx-ax),2)+pow((by-ay),2)); + printf("La distance entre les deux points est : %.2f\n", distance); + return EXIT_SUCCESS; +} + + +int main (void){ + double distance,angle,x,y; + printf("Donnez moi la distance et l'angle du point : \n"); + scanf("%lf", &distance); + scanf("%lf", &angle); + x= distance* cos(angle); + y= distance* sin(angle); + printf("En X le point est à : %.2f\n", x); + printf("En Y le point est à : %.2f\n", y); + return EXIT_SUCCESS; +} + + +int main (void){ + double reel; + int unite; + int dixieme; + printf("Entrez un réel : "); + scanf("%lf", &reel); + unite = (int)reel % 10; + dixieme = (int)(reel * 10) % 10; + printf("\nchiffre des unités : %d\n", unite); + printf("\nchiffre des dixièmes : %d\n", dixieme); + return EXIT_SUCCESS; +} diff --git a/DEV1.1/tableaux.c b/DEV1.1/tableaux.c index a6723e6..c82fe68 100644 --- a/DEV1.1/tableaux.c +++ b/DEV1.1/tableaux.c @@ -2,6 +2,7 @@ #include #include + int main (void){ int tableau[10]; int i; @@ -34,5 +35,64 @@ int main (void){ printf("%d", plus_grand); printf("\n"); + return EXIT_SUCCESS; +} + + +int main(void) { + srand(time(NULL)); + int min = 1; // Valeur minimale pour les nombres aléatoires + int max = 100; // Valeur maximale pour les nombres aléatoires + int i; + int tableau[10]; + int tableauInverse[10]; // Tableau pour stocker les valeurs inversées + + // Remplir le tableau avec des nombres aléatoires + for (i = 0; i < 10; i++) { + tableau[i] = min + rand() % (max - min + 1); + } + + // Afficher le tableau initial + printf("+"); + for (i = 0; i < 10; i++) { + printf("-----+"); + } + printf("\n"); + + for (i = 0; i < 10; i++) { + printf("|%5d", tableau[i]); + } + printf("|\n"); + + printf("+"); + for (i = 0; i < 10; i++) { + printf("-----+"); + } + printf("\n"); + + // Inverser l'ordre des valeurs + for (i = 0; i < 10; i++) { + tableauInverse[i] = tableau[9 - i]; + } + + // Afficher le tableau après inversion + printf("\nTableau après inversion:\n"); + printf("+"); + for (i = 0; i < 10; i++) { + printf("-----+"); + } + printf("\n"); + + for (i = 0; i < 10; i++) { + printf("|%5d", tableauInverse[i]); + } + printf("|\n"); + + printf("+"); + for (i = 0; i < 10; i++) { + printf("-----+"); + } + printf("\n"); + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/DEV1.1/tableaux_multi.c b/DEV1.1/tableaux_multi.c new file mode 100644 index 0000000..aaeb490 --- /dev/null +++ b/DEV1.1/tableaux_multi.c @@ -0,0 +1,153 @@ +#include +#include + +int main(void) { + int i,t1[2][5], t2[3][5], t3[5][5]; + + for (i=0; i<5;i++){ + t1[0][i] = i+1; + printf("%2d ", t1[0][i]); + } + printf("\n"); + for (i=0; i<5;i++){ + t1[1][i] = i+1; + printf("%2d ", t1[1][i]); + } + printf("\n\n"); + + for (i=0; i<5;i++){ + t2[0][i] = i+1; + printf("%2d ", t2[0][i]); + } + printf("\n"); + for (i=5; i<10;i++){ + t2[1][i] = i+1; + printf("%2d ", t2[1][i]); + } + printf("\n"); + for (i=10; i<15;i++){ + t2[2][i] = i+1; + printf("%2d ", t2[2][i]); + } + printf("\n\n"); + + for (i=0; i<5;i++){ + t3[0][i] = 0; + printf("%2d ", t3[0][i]); + } + + printf("\n"); + for (i=0; i<1;i++){ + t3[1][i] = i+1; + printf("%2d ", t3[1][i]); + } + for (i=1; i<5;i++){ + t3[1][i] = 0; + printf("%2d ", t3[1][i]); + } + printf("\n"); + + for (i=0; i<2;i++){ + t3[2][i] = i+1; + printf("%2d ", t3[2][i]); + } + for (i=2; i<5;i++){ + t3[2][i] = 0; + printf("%2d ", t3[2][i]); + } + printf("\n"); + + for (i=0; i<3;i++){ + t3[3][i] = i+1; + printf("%2d ", t3[3][i]); + } + for (i=3; i<5;i++){ + t3[2][i] = 0; + printf("%2d ", t3[3][i]); + } + printf("\n"); + + for (i=0; i<4;i++){ + t3[4][i] = i+1; + printf("%2d ", t3[4][i]); + } + for (i=4; i<5;i++){ + t3[4][i] = 0; + printf("%2d ", t3[4][i]); + } + return EXIT_SUCCESS; +} + + + +int main(void) { + int i,t1[2][5], t2[3][5], t3[5][5]; + + for (i=0; i<5;i++){ + t1[0][i] = i+1; + printf("%2d ", t1[0][i]); + } + printf (" "); + for (i=0; i<5;i++){ + t2[0][i] = i+1; + printf("%2d ", t2[0][i]); + } + printf (" "); + for (i=0; i<5;i++){ + t3[0][i] = 0; + printf("%2d ", t3[0][i]); + } + +printf("\n"); + + for (i=0; i<5;i++){ + t1[1][i] = i+1; + printf("%2d ", t1[1][i]); + } + printf (" "); + for (i=5; i<10;i++){ + t2[1][i] = i+1; + printf("%2d ", t2[1][i]); + } + printf (" "); + for (i=0; i<2;i++){ + t3[2][i] = i+1; + printf("%2d ", t3[2][i]); + } + for (i=2; i<5;i++){ + t3[2][i] = 0; + printf("%2d ", t3[2][i]); + } + +printf("\n"); + + printf(" "); + for (i=10; i<15;i++){ + t2[2][i] = i+1; + printf("%2d ", t2[2][i]); + } + printf (" "); + for (i=0; i<3;i++){ + t3[3][i] = i+1; + printf("%2d ", t3[3][i]); + } + for (i=3; i<5;i++){ + t3[2][i] = 0; + printf("%2d ", t3[3][i]); + } + + printf("\n"); + + printf(" "); + printf(" "); + printf(" "); + for (i=0; i<4;i++){ + t3[4][i] = i+1; + printf("%2d ", t3[4][i]); + } + for (i=4; i<5;i++){ + t3[4][i] = 0; + printf("%2d\n ", t3[4][i]); + } + return EXIT_SUCCESS; +} \ No newline at end of file