#N88BASIC


Function Distance(p1 As *POINTAPI, p2 As *POINTAPI) As Double
Distance = Sqr((p1->x - p2->x)^2 + (p1->y - p2->y)^2)
End Function


Sub InputP(mes As String, p As *POINTAPI)
If mes <> "" Then Print mes;
Input "x,y = ";p->x, p->y
End Sub


Sub PrintP(p As *POINTAPI)
Print "x=";p->x, "y=";p->y
End Sub

'ヘロンの公式
Function heron(a As Double, b As Double, c As Double) As Double
heron = Sqr(((a+b+c)*(a+b-c)*(b+c-a)*(c+a-b))/16)
End Function

'直交座標の式
Function chokou(p1 As *POINTAPI, p2 As *POINTAPI, p3 As *POINTAPI) As Double
Dim pp[2] As POINTAPI

pp[0].x = p2->x - p1->x
pp[0].y = p2->y - p1->y

pp[1].x = p3->x - p1->x
pp[1].y = p3->y - p1->y

chokou = Abs(pp[0].x * pp[1].y - pp[1].x * pp[0].y) / 2
End Function


Dim p[3] As POINTAPI
Dim d[3] As Double


InputP("点1:", VarPtr(p[0]))
InputP("点2:", VarPtr(p[1]))
InputP("点3:", VarPtr(p[2]))

d[0] = Distance(VarPtr(p[0]), VarPtr(p[1]))
d[1] = Distance(VarPtr(p[1]), VarPtr(p[2]))
d[2] = Distance(VarPtr(p[2]), VarPtr(p[0]))

Print "面積=";heron(d[0], d[1], d[2]);chokou(VarPtr(p[0]), VarPtr(p[1]), VarPtr(p[2]))