Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct souradnice {
- double x;
- double y;
- };
- const int n = 50;
- double obsah(double a, double b, double c)
- {
- double s = (a + b + c) / 2;
- double S = 0;
- S = sqrt(s*(s - a)*(s - b)*(s - c));
- return S;
- }
- int main(void)
- {
- souradnice bodu[n];
- ifstream vstup("Points.txt");
- for (int i = 0; i < n; i++)
- {
- vstup >> bodu[i].x >> bodu[i].y;
- cout << bodu[i].x << " " << bodu[i].y << endl;
- double Ax = bodu[i].x;
- double Ay = bodu[i].y;
- 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
- double By = bodu[i].y;
- double Cx = bodu[i].x;
- double Cy = bodu[i].y;
- double a = sqrt((Bx - Cx)*(Bx - Cx) + (By - Cy)*(By - Cy));
- double b = sqrt((Ax - Cx)*(Ax - Cx) + (Ay - Cy)*(Ay - Cy));
- double c = sqrt((Ax - Bx)*(Ax - Bx) + (Ay - By)*(Ay - By));
- double obs = obsah(s, a, b, c);
- cout << obs << endl;
- }
- vstup.close();
- system("pause");
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement