From abf065d231979da5f4b7d8438dea9f2116238e33 Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Tue, 5 Oct 2021 14:15:08 +0200 Subject: [PATCH] =?UTF-8?q?TP10=20R=C3=A9els=2002?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APL1.1/TP10/chiffres.c | 17 +++++++++++++++++ APL1.1/TP10/distance.c | 19 +++++++++++++++++++ APL1.1/TP10/duree_de_vol.c | 21 +++++++++++++++++++++ APL1.1/TP10/formules.c | 8 +++++++- 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 APL1.1/TP10/chiffres.c create mode 100644 APL1.1/TP10/distance.c create mode 100644 APL1.1/TP10/duree_de_vol.c diff --git a/APL1.1/TP10/chiffres.c b/APL1.1/TP10/chiffres.c new file mode 100644 index 0000000..67b4663 --- /dev/null +++ b/APL1.1/TP10/chiffres.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char * argv[]) { + double x; + printf("Veuillez donner un réel : "); + scanf("%lf", &x); + + int partie_entiere = (int)trunc(x) % 10; + int dixieme = (int)trunc(x*10) % 10; + + printf("Chiffre des unités : %d\n", partie_entiere); + printf("Chiffre des dixieme : %d\n", dixieme); + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP10/distance.c b/APL1.1/TP10/distance.c new file mode 100644 index 0000000..dd51a69 --- /dev/null +++ b/APL1.1/TP10/distance.c @@ -0,0 +1,19 @@ +#include +#include +#include + +double dist(float x1, float y1, float x2, float y2) { + return sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)); +} + +int main(int argc, char * argv[]) { + + float x1, y1, x2, y2; + + printf("Veuillez indiquer vos deux points sous la forme x1,y1 x2,y2 : "); + scanf("%f,%f %f,%f", &x1, &y1, &x2, &y2); + + printf("La distance entre %.2f,%.2f et %.2f,%.2f est de ~%.5f\n", x1, y1, x2, y2, dist(x1,y1,x2,y2)); + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP10/duree_de_vol.c b/APL1.1/TP10/duree_de_vol.c new file mode 100644 index 0000000..52442dc --- /dev/null +++ b/APL1.1/TP10/duree_de_vol.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int main(int argc, char * argv[]) { + double airspeed, windspeed, distance; + + printf("Veuillez donner la vitesse de l'avion, du vent et la distance à parcourir : "); + scanf("%lf %lf %lf", &airspeed, &windspeed, &distance); + + double groundspeed = airspeed - windspeed; + double hoursmins = distance / groundspeed; + int hours = trunc(hoursmins); + int mins = (int)((hoursmins-hours) * 60); + + + printf("Le vol durera ~%d heure%s et %d minute%s.\n", + hours, hours > 1 ? "s" : "", mins, mins > 1 ? "s" : ""); + return EXIT_SUCCESS; +} + diff --git a/APL1.1/TP10/formules.c b/APL1.1/TP10/formules.c index 53078aa..5cb3def 100644 --- a/APL1.1/TP10/formules.c +++ b/APL1.1/TP10/formules.c @@ -1,8 +1,14 @@ #include #include +#include int main(int argc, char * argv[]) { - + printf("sqrt(ln(0.5)) = %lf\n", sqrt(log(0.5))); + printf("sin(pi/6) = %lf\n", sin(3.1415926535898/6)); + printf("arctan(13²) = %lf\n", atan(pow(13, 2))); + printf("(e^-1)⁴ = %lf\n", pow(exp(-1), 4)); + printf("ln(-3) = %lf\n", log(-3)); + printf("sqrt(2)² = %lf\n", pow(sqrt(2), 2)); return EXIT_SUCCESS; }