APL/APL1.1/TP10/distance.c
2021-10-05 14:15:08 +02:00

20 lines
465 B
C

#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;
}