TP10 Réels 02
This commit is contained in:
parent
0692ffc6d6
commit
abf065d231
17
APL1.1/TP10/chiffres.c
Normal file
17
APL1.1/TP10/chiffres.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
19
APL1.1/TP10/distance.c
Normal file
19
APL1.1/TP10/distance.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
21
APL1.1/TP10/duree_de_vol.c
Normal file
21
APL1.1/TP10/duree_de_vol.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,14 @@
|
|||||||
#include<stdio.h>
|
#include<stdio.h>
|
||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
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;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user