題目描述
本題為填空題,只需要算出結(jié)果后,在代碼中使用輸出語句將所填結(jié)果輸出即可。
已知三角形三個頂點(diǎn)在直角坐標(biāo)系下的坐標(biāo)分別為:
```txt (2.3, 2.5) (6.4, 3.1) (5.1, 7.2)
```txt 求該三角形的面積。
注意,要提交的是一個小數(shù)形式表示的浮點(diǎn)數(shù)。 要求精確到小數(shù)后?3?位,如不足?3?位,需要補(bǔ)零。
運(yùn)行限制
- 最大運(yùn)行時間:1s
- 最大運(yùn)行內(nèi)存: 128M
???????
其中,p=周長/2
A、B兩點(diǎn)距離:文章來源:http://www.zghlxwxcb.cn/news/detail-706415.html
其中,假設(shè)A(x1,y1),B(x2,y2)文章來源地址http://www.zghlxwxcb.cn/news/detail-706415.html
import java.util.*;
public class Main {
public static void main(String[] args) {
double x1=2.3,y1=2.5;
double x2=6.4,y2=3.1;
double x3=5.1,y3=7.2;
double n1=liangdian(x1,y1,x2,y2);
double n2=liangdian(x1,y1,x3,y3);
double n3=liangdian(x2,y2,x3,y3);
double S=(n1+n2+n3)/2;
double ans=Math.sqrt(S*(S-n1)*(S-n2)*(S-n3));
System.out.printf("%.3f",ans);
}
public static double liangdian(double x1,double y1,double x2,double y2){
double x=Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
return x;
}
}
到了這里,關(guān)于藍(lán)橋杯官網(wǎng)填空題(三角形的面積)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!