文章
34
粉丝
89
获赞
2
访问
19.2k
#include<cstdio> #include<iostream> #include<string> #include<map> #include<cmath> using namespace std; double SideLength(int x1,int y1,int x2,int y2){ int a = abs(x1 - x2); int b = abs(y1 - y2); return sqrt(pow(a,2)+pow(b,2)); } int main(){ int x1,y1,x2,y2,x3,y3; while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3) != EOF){ double len1 = SideLength(x1,y1,x2,y2); double len2 = SideLength(x1,y1,x3,y3); double len3 = SideLength(x2,y2,x3,y3); double p = (len1 + len2 + len3) / 2;//周长的一半 double area = sqrt(p*(p-len1)*(p-len2)*(p-len3));//海伦公式 printf("%.2lf\n",area); // cout << area << endl; } }
登录后发布评论
暂无评论,来抢沙发