1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <stdio.h>
int main(void){
/*declaration des variable*/
double x1, x2, x3, x4, y1, y2, y3, y4;
double xi, yi;
/* entré des valeurs */
puts(" saisir le point 1 (x1, y1) ");
scanf("%lf %lf", &x1 ,&y1);
puts(" saisir le point 2 (x2, y2) ");
scanf("%lf %lf", &x2 ,&y2);
puts(" saisir le point 3 (x3, y3) ");
scanf("%lf %lf", &x3 ,&y3);
puts(" saisir le point 4 (x4, y4) ");
scanf("%lf %lf", &x4 ,&y4);
/* formule du point d'intersection */
xi = ((x3 * y4 - x4 * y3) * (x1 - x2) - (x1 * y2 - x2 * y1) * (x3 - x4)) / ((y1 - y2) * (x3 - x4) - (y3 - y4) * (x1 - x2));
yi = xi * ((y1 - y2)/(x1 - x2)) + ((x1 * y2 - x2 * y1)/(x1 - x2));
/*Affichage du resultat */
printf("le point d'intersection vaut I(%lf, %lf)\n", xi, yi);
system("PAUSE"); /* si on utilise pas visual */
return 0;
} |
Partager