Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5. double x1, y1, x2, y2, x3, y3;
  6. scanf_s("%lf%lf%lf%lf%lf%lf\n", &x1, &y1, &x2, &y2, &x3, &y3);
  7. double a, b, c;
  8. a = sqrt((abs(pow(x1 - x2,2))) + (abs(pow(y1 - y2,2))));
  9. b = sqrt((abs(pow(x1 - x3, 2))) + (abs(pow(y1 - y3, 2))));
  10. c = sqrt((abs(pow(x2 - x3, 2))) + (abs(pow(y2 - y3, 2))));
  11. double perimeter = a + b + c;
  12. double area = 1 / 2 * abs(x1*y2 - x2 * y1 - x3 * y2 + x2 * y3 + x3 * y1 - x1 * y3);
  13. char command;
  14. scanf_s("%c", &command);
  15.  
  16. switch (command)
  17. {
  18. case 'u': printf("Umfang = %lf", perimeter); break;
  19. case 's': printf("Flaeche = %lf", area); break;
  20. default: printf("Ungueltig!");
  21. break;
  22. }
  23. system("pause");
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement