From d7c69934248f3fab4988c0d37c11feba25d653b8 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 31 Jan 2025 15:39:30 +0100 Subject: =?UTF-8?q?Ajout=20du=20d=C3=A9but=20du=20deuxi=C3=A8me=20semestre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- semestre 2/informatique/td/1- exemples/constant.c | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 semestre 2/informatique/td/1- exemples/constant.c (limited to 'semestre 2/informatique/td/1- exemples/constant.c') diff --git a/semestre 2/informatique/td/1- exemples/constant.c b/semestre 2/informatique/td/1- exemples/constant.c new file mode 100644 index 0000000..37864ae --- /dev/null +++ b/semestre 2/informatique/td/1- exemples/constant.c @@ -0,0 +1,26 @@ +#include + +#define TNORMAL 11.4 +#define TMOINS 4.5 +#define TMOINS26S 4.9 +#define TMOINS26WE 7.9 +#define TMATIN 7.1 + +float prixPlace(int age, int jour, float h){ + if (age < 14) return TMOINS; + if (age < 26 && jour < 6) return TMOINS26S; + if (h < 11 && h > 8) return TMATIN; + if (age < 26) return TMOINS26WE; + return TNORMAL; +} + +int main(){ + printf("%.2f€ prix pour %d ans le %de jour de la semaine à %.1fh\n", prixPlace(13, 5, 13), 13, 5, 13.0); + printf("%.2f€ prix pour %d ans le %de jour de la semaine à %.1fh\n", prixPlace(14, 5, 13), 14, 5, 13.0); + printf("%.2f€ prix pour %d ans le %de jour de la semaine à %.1fh\n", prixPlace(14, 6, 13), 14, 6, 13.0); + printf("%.2f€ prix pour %d ans le %de jour de la semaine à %.1fh\n", prixPlace(14, 6, 10), 14, 6, 10.0); + printf("%.2f€ prix pour %d ans le %de jour de la semaine à %.1fh\n", prixPlace(28, 6, 10), 28, 6, 10.0); + printf("%.2f€ prix pour %d ans le %de jour de la semaine à %.1fh\n", prixPlace(28, 6, 15), 28, 6, 15.0); + return 0; +} + -- cgit v1.2.3