标签:周赛
Description
Input
Output
Sample Input
3 0 0 1 0 0 1 4 1 0 0 1 -1 0 0 -1 0
Sample Output
0.5 2.0#include <iostream> #include <stdio.h> #include <cmath> using namespace std; double mianji(int x1,int y1,int x2, int y2, int x3, int y3) { int p = (x1-x2)*(y1-y3) - (y1-y2)*(x1-x3); double num = (double)p / 2; return num; } int main() { int n; int a[110], b[110]; while (cin >>n && n) { for (int i=0; i<n; i++) { cin >> a[i] >> b[i]; } double result = 0; for (int i=2; i<n; i++) { result = result + mianji(a[0],b[0],a[i-1],b[i-1],a[i],b[i]); } printf("%.1lf\n",result); } return 0; }
标签:周赛
原文地址:http://blog.csdn.net/xiaotan1314/article/details/46399455