# Формулы

Jan 28th, 2022
836
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. /***
2. Геомтерия
3. ***/
4. #include <bits/stdc++.h>
5.
6. using namespace std;
7.
8. double dist(double x, double y, double x2, double y2) {
9.     double d = sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
10.     return d;
11. }
12.
13. double area(double x, double y, double x2, double y2, double x3, double y3) {
14.     double a = dist(x, y, x2, y2);
15.     double b = dist(x, y, x3, y3);
16.     double c = dist(x2, y2, x3, y3);
17.     double u = (a + b + c) / 2;
18.     double S = sqrt(u * (u - a) * (u - b) * (u - c));
19.     return S;
20. }
21.
22. int main(){
23.     int n;
24.     cin >> n;
25.
26.     int x[n + 1], y[n + 1];
27.     for (int i = 1; i <= n; i++) {
28.         cin >> x[i] >> y[i];
29.     }
30.
31.     double s1 = 0, s2 = 0;
32.     for (int i = 1; i < n; i++) {
33.         s1 += x[i] * y[i + 1];
34.         s2 += y[i] * x[i + 1];
35.     }
36.
37.     s1 += x[n] * y[1];
38.     s2 += y[n] * x[1];
39.
40.     double S = fabs(s1 - s2) / 2;
41. }
42.