Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. void main(void)
  4. {
  5. float coefficienteangolare1, terminenoto1, coefficienteangolare2, terminenoto2;
  6. printf("Questo programma calcola, date due rette nella forma y=mx+q, la loro intersezione.\n");
  7. printf("Inserire coefficiente angolare e termine noto della prima retta: ");
  8. scanf("%f%f", &coefficienteangolare1, &terminenoto1);
  9. printf("La prima retta e' y = %f x + %f\n", coefficienteangolare1, terminenoto1);
  10. printf("Inserire coefficiente angolare e termine noto della seconda retta: ");
  11. scanf("%f%f", &coefficienteangolare2, &terminenoto2);
  12. printf("La seconda retta e' y = %f x + %f\n", coefficienteangolare2, terminenoto2);
  13.  
  14. /* Date due rette del tipo y=ax+b e y=cx+d, l'intersezione รจ ax+b = cx+d, ovvero x(a-c)=d-b, quindi x=d-b/a-c */
  15.  
  16. float x, y;
  17. x = (terminenoto2 - terminenoto1) / (coefficienteangolare1 - coefficienteangolare2);
  18. y = coefficienteangolare1 * x + terminenoto1;
  19. printf("Il punto di intersezione ha ascissa %f e ordinata %f\n", x, y);
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement