Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define x first
- #define y second
- using namespace std;
- int getsquere(pair<int, int> p1, pair<int,int> p2){
- return (p1.y + p2.y) * (p2.x - p1.x);
- }
- int main() {
- int N;
- cin >> N;
- pair<int, int> coords[N];
- for (int i=0;i<N;i++){
- cin >> coords[i].x;
- cin >> coords[i].y;
- }
- int s = 0;
- for (int i=0;i<N;i++){
- if (i!=0){
- s += getsquere(coords[i-1], coords[i]);
- }else{
- s += getsquere(coords[N-1], coords[0]);
- }
- }
- printf("%.1f", fabs(((double)s)/2));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement