如何计算三点面积
题目:http://acm.swust.edu.cn/oj/problem/848/
代码:
View Code
#include "stdio.h" #include "string.h" #include "stdlib.h" #include "math.h" #include "iostream" #include "ctime" using namespace std; typedef struct node{ double x, y; }node; double Cal_Area(node o, node f1, node f2){ return fabs((f1.x-o.x)*(f2.y-o.y)-(f1.y-o.y)*(f2.x-o.x))/2.0; } int main(){ node p[3]; while(scanf("%lf%lf%lf%lf%lf%lf", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y)!=EOF){ printf("%.2lf\n", Cal_Area(p[0], p[1], p[2])); } }
posted on 2012-05-18 22:37 More study needed. 阅读(423) 评论(0) 编辑 收藏 举报