本人出一个,等大神们的代码~
Dim $AB, $BC, $CD, $AD
Dim $S
Dim $AC
Dim $P1, $p2
Dim $flag = 0
GUICreate("求对角线", 400, 300)
$ABl = GUICtrlCreateInput("3", 100, 50)
$BCl = GUICtrlCreateInput("4", 100, 90)
$CDl = GUICtrlCreateInput("3", 100, 130)
$ADl = GUICtrlCreateInput("4", 100, 170)
$Ss = GUICtrlCreateInput("12", 100, 210)
$B = GUICtrlCreateButton("计 算", 100, 260, 80)
GUICtrlCreateLabel("输入AB的长", 20, 50)
GUICtrlCreateLabel("输入BC的长", 20, 90)
GUICtrlCreateLabel("输入CD的长", 20, 130)
GUICtrlCreateLabel("输入AD的长", 20, 170)
GUICtrlCreateLabel("输入面积S", 20, 210)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $B
$AB = GUICtrlRead($ABl)
$BC = GUICtrlRead($BCl)
$CD = GUICtrlRead($CDl)
$AD = GUICtrlRead($ADl)
$S = GUICtrlRead($Ss)
count()
EndSwitch
WEnd
Func count()
For $AC = $AB To ($AB + $BC)
$P1 = ($AB + $BC + $AC) / 2
$p2 = ($AD + $CD + $AC) / 2
If Sqrt($P1 * ($P1 - $AB) * ($P1 - $BC) * ($P1 - $AC)) * 2 = $S Then
MsgBox(0, "", "对角线AC的长度为:" & $AC)
$flag = 1
Else
If $AC = ($AB + $BC) And $flag = 0 Then MsgBox(0, "", "该尺寸的四边形不存在!")
EndIf
Next
$flag = 0
EndFunc ;==>count
|