标签:style blog io color os sp strong 数据 div
描述
给你三个点,表示一个三角形的三个顶点,现你的任务是求出该三角形的面积
0 0 1 1 1 3 0 1 1 0 0 0 0 0 0 0 0 0
1.0 0.5
#include <iostream> #include <string.h> #include <iomanip> #include <cmath> using namespace std; int main() { int x1,y1,x2,y2,x3,y3; double a,b,c,p,s; while(cin>>x1>>y1>>x2>>y2>>x3>>y3 ) { if(x1==0&&y1==0&&x2==0&&y2==0&&x3==0&&y3==0) break; else { a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)); c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)); p=(a+b+c)/2; s=sqrt(p*(p-a)*(p-b)*(p-c)); cout<<fixed<<setprecision(1)<<s<<endl; } } return 0; }
标签:style blog io color os sp strong 数据 div
原文地址:http://www.cnblogs.com/imwtr/p/4069478.html