文章
72
粉丝
142
获赞
5
访问
57.5k
#include<bits/stdc++.h>
using namespace std;
double length(int x1,int y1,int x2,int y2) {
double ans = 0;
ans = sqrt((x2-x1)*(x2 - x1)+(y2-y1)* (y2 - y1));
return ans;
}
int main() {
double x1, y1, x2, y2, x3, y3;
while (cin>>x1>>y1>>x2>>y2>>x3>>y3) {
//计算边长
double a = length(x1, y1, x2, y2);
double b = length(x1, y1, x3, y3);
double c = length(x2, y2, x3, y3);
double p = (a + b + c) / 2;
double ans = sqrt(p*(p-a)*(p-b)*(p-c));
printf("%.2lf\n",ans);
}
return 0;
}
登录后发布评论
length函数的参数怎么是int