Dimitar23308

29.1

Jan 29th, 2026
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. float x1, y1, x2, y2, x3, y3;
  8.  
  9. cout << "Tochka 1 (x y): "; cin >> x1 >> y1;
  10. cout << "Tochka 2 (x y): "; cin >> x2 >> y2;
  11. cout << "Tochka 3 (x y): "; cin >> x3 >> y3;
  12.  
  13. float a = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
  14. float b = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
  15. float c = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  16.  
  17. if (a + b > c && a + c > b && b + c > a) {
  18. float P = a + b + c;
  19. float p = P / 2;
  20. float S = sqrt(p * (p - a) * (p - b) * (p - c));
  21.  
  22. cout << "Perimetur: " << P << endl;
  23. cout << "Lice: " << S << endl;
  24. } else {
  25. cout << "Ne moje da ima triugulnik!" << endl;
  26. }
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment