Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double check_triangle(x1, y1, x2, y2, x3, y3, d1, d2, d3) //בדיקה האם זה משולש
  5. {
  6. d1 = sqrt((pow((y2 - y1), 2) + pow((x2 - x1), 2)));
  7. d2 = sqrt((pow((y3 - y1), 2) + pow((x3 - x1), 2)));
  8. d3 = sqrt((pow((y3 - y2), 2) + pow((x3 - x2), 2)));
  9. return d1;
  10. return d2;
  11. return d3;
  12. }
  13.  
  14. void main()
  15. {
  16. double x1, y1, x2, y2, x3, y3, d1 = 0, d2 = 0, d3 = 0;
  17. printf("Enter 3 coordinates:\n");
  18. scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
  19. check_triangle(x1, y1, x2, y2, x3, y3, d1, d2, d3);
  20. if ((d1 + d2) > d3 || (d1 + d3) > d2 || (d3 + d2) > d1)
  21. {
  22. printf("Its a triangle.\nlets check what kind of triangle is it");
  23. if ((d1 == d2) != d3 || (d2 == d3) != d1 || (d1 == d3) != d2)
  24. {
  25. printf("its a Isosceles triangle");
  26. if ((pow(d1, 2) + pow(d2, 2)) == pow(d3, 2) || (pow(d3, 2) + pow(d2, 2)) == pow(d1, 2) || (pow(d1, 2) + pow(d3, 2)) == pow(d2, 2))
  27. printf("And its Right triangle");
  28. }
  29. else if (d1 == d2 == d3)
  30. {
  31. printf("Its a Equilateral triangle, and its cant be Right triagnle");
  32. }
  33. }
  34. else
  35. printf("Its not a triangle.");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement