标签:hdu 必须 ble sample 输入数据 div stream turn fixed
#include "iostream" #include "iomanip" using namespace std; double Area(int *x,int *y,int n) { double s=0; for(int i=0;i<n;i++) { int j=(i+1)%n; s+=x[i]*y[j]; s-=x[j]*y[i]; } s/=2; return (s>0?s:-s); //大于零说明点是按顺时针排列的,小于零则相反 } int main() { int n,i; int x[100],y[100]; double area; while(cin>>n && n) { for(int i=0;i<n;i++) cin>>x[i]>>y[i]; area=Area(x,y,n); cout<<setprecision(1)<<setiosflags(ios::fixed) <<area<<endl; } return 0; }
标签:hdu 必须 ble sample 输入数据 div stream turn fixed
原文地址:http://www.cnblogs.com/tenjl-exv/p/8011346.html