hdoj:2036
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdoj:2036相关的知识,希望对你有一定的参考价值。
#include <iostream> using namespace std; struct Point { int x, y; }; Point a[101]; int main() { int n; while (cin >> n && n != 0) { for (int i = 1; i <= n; i++) { cin >> a[i].x >> a[i].y; } double area = 0.0; for (int i = 1; i < n; i++) { int x1 = a[i].x; int y1 = a[i].y; int x2 = a[i + 1].x; int y2 = a[i + 1].y; area += 0.5*abs(x1*y2 - y1*x2); } int x1 = a[1].x; int y1 = a[1].y; int x2 = a[n].x; int y2 = a[n].y; area += 0.5*abs(x1*y2 - y1*x2); printf("%.1lf\n", area); } }
以上是关于hdoj:2036的主要内容,如果未能解决你的问题,请参考以下文章