[C++] 纯文本查看 复制代码
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Compile_Both=y
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Date.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;~ #include <bug.au3>
#Region ### START Koda GUI section ### Form=e:\au3\project\随机数生成器\form1.kxf
$Form1_1 = GUICreate("Form1", 453, 172, 192, 124)
$Input1 = GUICtrlCreateInput("-0.5", 63, 72, 73, 21)
$Input2 = GUICtrlCreateInput("0.5", 207, 72, 73, 21)
$Input3 = GUICtrlCreateInput("3", 351, 72, 73, 21)
$Label1 = GUICtrlCreateLabel("下限:", 8, 74, 40, 17)
$Label2 = GUICtrlCreateLabel("上限:", 160, 75, 40, 17)
$Label3 = GUICtrlCreateLabel("小数位:", 295, 75, 52, 17)
;~ $Input4 = GUICtrlCreateInput("", 64, 118, 241, 21)
;~ $Label4 = GUICtrlCreateLabel("随机数:", 8, 120, 52, 17)
$Button1 = GUICtrlCreateButton("计算", 336, 104, 89, 41)
$Input5 = GUICtrlCreateInput("2", 65, 29, 73, 21)
$Input6 = GUICtrlCreateInput("20", 209, 29, 73, 21)
$Label5 = GUICtrlCreateLabel("平均数:", 10, 31, 52, 17)
$Label6 = GUICtrlCreateLabel("个数:", 162, 32, 40, 17)
$Label7 = GUICtrlCreateLabel("点击计算按钮开始吧!", 296, 30, 200, 30)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_suijishu()
EndSwitch
WEnd
Func _suijishu()
Local $rand, $yushu
$yushu = GUICtrlRead($Input5) * GUICtrlRead($Input6)
Local $num = 0
While 1
$num = $num + 1
GUICtrlSetData($Label7, "正在进行第" & $num & "次尝试")
If $yushu < (GUICtrlRead($Input2) + GUICtrlRead($Input5)) Then
If $yushu < (GUICtrlRead($Input1) + GUICtrlRead($Input5)) Then
$yushu = GUICtrlRead($Input5) * GUICtrlRead($Input6)
Local $file = FileOpen("test.txt", 10)
For $i = 1 To GUICtrlRead($Input6) - 1
SRandom(StringReplace(_NowTime(), ":", "") + $i)
$rand = Round(Random(GUICtrlRead($Input1) + GUICtrlRead($Input5), GUICtrlRead($Input2) + GUICtrlRead($Input5)), GUICtrlRead($Input3))
FileWriteLine($file, $rand & @CRLF)
$yushu = $yushu - $rand
Next
Else
ExitLoop
EndIf
Else
$yushu = GUICtrlRead($Input5) * GUICtrlRead($Input6)
Local $file = FileOpen("test.txt", 10)
For $i = 1 To GUICtrlRead($Input6) - 1
SRandom(StringReplace(_NowTime(), ":", "") + $i)
$rand = Round(Random(GUICtrlRead($Input1) + GUICtrlRead($Input5), GUICtrlRead($Input2) + GUICtrlRead($Input5)), GUICtrlRead($Input3))
FileWriteLine($file, $rand & @CRLF)
$yushu = $yushu - $rand
Next
EndIf
WEnd
FileWriteLine($file, $yushu & @CRLF)
GUICtrlSetData($Label7, "共进行了" & $num & "次尝试")
;~ MsgBox(0, 0, $yushu)
FileClose($file)
EndFunc ;==>_suijishu