APL/APL1.1/TP10/duree_de_vol.c

22 lines
582 B
C
Raw Permalink Normal View History

2021-10-05 14:15:08 +02:00
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
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;
}