Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ButtonConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- #include <ListViewConstants.au3>
- #Region ### START Koda GUI section ### Form=
- $Form1 = GUICreate("Giải phương trình bậc 2", 300, 246)
- GuiSetIcon (@SystemDir & "\mspaint.exe" , 0)
- $Label1 = GUICtrlCreateLabel("Nhập a:", 20, 35, 40, 17)
- $Label2 = GUICtrlCreateLabel("Nhập b:", 20, 62, 40, 17)
- $Label3 = GUICtrlCreateLabel("Nhập c:", 20, 93, 40, 17)
- $Label4 = GUICtrlCreateLabel("Phương trình có dạng: ax^2 + bx + c = 0", 16, 8, 194, 17)
- $Input1 = GUICtrlCreateInput("", 63, 34, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
- $Input2 = GUICtrlCreateInput("", 64, 62, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
- $Input3 = GUICtrlCreateInput("", 63, 90, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
- $Button1 = GUICtrlCreateButton("Let's go", 163, 62, 113, 25, $BS_DEFPUSHBUTTON)
- $Label5 = GUICtrlCreateLabel("Phương trình có nghiệm:", 24, 128,200, 17)
- $ListView1 = GUICtrlCreateListView("a|b|c|x1|x2", 24, 144, 255, 81)
- GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 0, 50)
- GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 1, 50)
- GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 2, 50)
- GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 3, 50)
- GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 4, 50)
- $Label7 = GUICtrlCreateLabel("", 144, 35, 200, 17)
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- Case $Button1
- b()
- EndSwitch
- WEnd
- Func pt()
- $a = GUICtrlRead($Input1)
- $b = GUICtrlRead($Input2)
- $c = GUICtrlRead($Input3)
- $denta = ($b^2) - 4*$a*$c
- $x1 = ((-$b) + Sqrt($denta)) / (2*$a)
- $x2 = ((-$b) - Sqrt($denta)) / (2*$a)
- GUICtrlSetData($label7,"")
- If $denta < 0 Then
- MsgBox (0, "Phương trình","Vô nghiệm!")
- $x1 = ""
- $x2 = ""
- ElseIf $denta = 0 Then
- MsgBox(0, "Phương trình","Có nghiệm kép x1 = x2 = " & $x1)
- Else
- MsgBox(0,"Phương trình","Có 2 nghiệm" & @CRLF & "x1 = " & $x1 & @CRLF & "x2 = " & $x2)
- EndIf
- GUICtrlCreateListViewItem($a & "|" & $b & "|" & $c & "|" & $x1 & "|" & $x2,$ListView1)
- EndFunc
- func b()
- If GUICtrlRead($Input1) <> 0 And StringIsInt(GUICtrlRead($Input2)) And StringIsInt(GUICtrlRead($Input3)) Then
- pt()
- Else
- GUICtrlSetData($label7,"a,b,c phải là số, a khác 0")
- EndIf
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement