Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double check_triangle(x1, y1, x2, y2, x3, y3, d1, d2, d3) //בדיקה האם זה משולש
- {
- d1 = sqrt((pow((y2 - y1), 2) + pow((x2 - x1), 2)));
- d2 = sqrt((pow((y3 - y1), 2) + pow((x3 - x1), 2)));
- d3 = sqrt((pow((y3 - y2), 2) + pow((x3 - x2), 2)));
- return d1;
- return d2;
- return d3;
- }
- void main()
- {
- double x1, y1, x2, y2, x3, y3, d1 = 0, d2 = 0, d3 = 0;
- printf("Enter 3 coordinates:\n");
- scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
- check_triangle(x1, y1, x2, y2, x3, y3, d1, d2, d3);
- if ((d1 + d2) > d3 || (d1 + d3) > d2 || (d3 + d2) > d1)
- {
- printf("Its a triangle.\nlets check what kind of triangle is it");
- if ((d1 == d2) != d3 || (d2 == d3) != d1 || (d1 == d3) != d2)
- {
- printf("its a Isosceles triangle");
- 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))
- printf("And its Right triangle");
- }
- else if (d1 == d2 == d3)
- {
- printf("Its a Equilateral triangle, and its cant be Right triagnle");
- }
- }
- else
- printf("Its not a triangle.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement