Cod sursa(job #2222598)

Utilizator claudiu.gatinaFMI Claudiu Gatina claudiu.gatina Data 17 iulie 2018 14:10:35
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.73 kb
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

map<int, int> contor;

int main()
{
    freopen("aria.in", "r", stdin);
    freopen("aria.out", "w", stdout);
    int n;
    double aria = 0;
    scanf("%d", &n);
    double x1, x2, x3, y1, y2, y3;
    scanf("%lf", &x1);
    scanf("%lf", &y1);

    scanf("%lf", &x2);
    scanf("%lf", &y2);

    if(n <= 2)
      printf("0");
    else
    {
      for(int i = 2; i < n; ++i)
      {
        scanf("%lf", &x3);
        scanf("%lf", &y3);
        aria += abs(x1 * y2 + x2 * y3 + x3 * y1 - x3 * y2 - x2 * y1 - x1 * y3);
        x2 = x3;
        y2 = y3;
      }
      printf("%.6lf", aria / 2);
    }


    return 0;
}