Advertisement
Guest User

Untitled

a guest
Dec 13th, 2016
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. struct souradnice {
  5. double x;
  6. double y;
  7. };
  8.  
  9. const int n = 50;
  10. double obsah(double a, double b, double c)
  11. {
  12. double s = (a + b + c) / 2;
  13. double S = 0;
  14. S = sqrt(s*(s - a)*(s - b)*(s - c));
  15. return S;
  16. }
  17.  
  18. int main(void)
  19. {
  20. souradnice bodu[n];
  21. ifstream vstup("Points.txt");
  22. for (int i = 0; i < n; i++)
  23. {
  24. vstup >> bodu[i].x >> bodu[i].y;
  25. cout << bodu[i].x << " " << bodu[i].y << endl;
  26. double Ax = bodu[i].x;
  27. double Ay = bodu[i].y;
  28. double Bx = bodu[i].x; //nevím jak přiřadit ty body A,B,C - nwm jestli jsem pochopil dobře zadání, protože teď samozřejmě vyjde blbost
  29. double By = bodu[i].y;
  30. double Cx = bodu[i].x;
  31. double Cy = bodu[i].y;
  32. double a = sqrt((Bx - Cx)*(Bx - Cx) + (By - Cy)*(By - Cy));
  33. double b = sqrt((Ax - Cx)*(Ax - Cx) + (Ay - Cy)*(Ay - Cy));
  34. double c = sqrt((Ax - Bx)*(Ax - Bx) + (Ay - By)*(Ay - By));
  35. double obs = obsah(s, a, b, c);
  36. cout << obs << endl;
  37. }
  38. vstup.close();
  39. system("pause");
  40. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement