Pagini recente » Cod sursa (job #1947661) | Cod sursa (job #3293926) | Cod sursa (job #2268901) | Cod sursa (job #3283802) | Cod sursa (job #1257617)
#include <fstream>
#include <iomanip>
using namespace std;
long double areaTri(long double x0, long double y0, long double x1, long double y1) {
/*
| 1 0 0 |
| 1 x0 y0 |
| 1 x1 y1 |
*/
return x0 * y1 - x1 * y0;
}
int main() {
ifstream f("aria.in",ios::in);
ofstream g("aria.out",ios::out);
long double n;
f >> n;
long double cnt = 0.0;
if(n > 1) {
long double x0, y0;
f >> x0 >> y0;
long double x0s,y0s,x1,y1, xt, yt;
x0s = x0, y0s = y0;
f >> x1 >> y1;
cnt += areaTri(x0, y0, x1, y1);
for(int i = 2; i < n; i++) {
f >> xt >> yt;
x0 = x1, y0 = y1, x1 = xt, y1 = yt;
cnt += areaTri(x0,y0,x1,y1);
}
cnt += areaTri(x1,y1,x0s,y0s);
}
g << fixed << setprecision(5) << cnt / 2.0 << endl;
return 0;
}