scoaladehack | Date: Friday, 2009-10-09, 3:41 PM | Message # 1 |
Private
Group: Administratori
Messages: 4
Status: Offline
| Rezolvarea completa va este scrisa intr-un fisier numit "rezolvare.txt". Code #include #include #include #NoTrayIcon
$gui = GUICreate("Ec.Gr.2.by.Cyber", 260, 93) $a_label = GUICtrlCreateLabel("a= ", 4, 5, 15, 18) $a_input = GUICtrlCreateInput("", 20, 4, 30, 19) $b_label = GUICtrlCreateLabel("b= ", 54, 5, 15, 18) $b_input = GUICtrlCreateInput("", 70, 4, 30, 19) $c_label = GUICtrlCreateLabel("c= ", 104, 5, 15, 18) $c_input = GUICtrlCreateInput("", 120, 4, 30, 19) $calculate = GUICtrlCreateButton("Calculeaza", 154, 4, 104, 19) $delta_box = GUICtrlCreateLabel("Delta=", 4, 30, 60, 19) $x1_box = GUICtrlCreateLabel("x1=", 68, 30, 45, 19) $x2_box = GUICtrlCreateLabel("x2=", 117, 30, 45, 19) $rad_delta_box = GUICtrlCreateLabel("Rad. Delta=", 166, 30, 90, 19) $reset = GUICtrlCreateButton("------------------------Reseteaza------------------------", 4, 53, 252, 18) $open = GUICtrlCreateButton("---------------------Arata Rezolvarea---------------------", 4, 73, 252, 18)
GUISetBkColor(0x000000, $gui) GUICtrlSetColor($a_label, 0xFFFFFF) GUICtrlSetColor($b_label, 0xFFFFFF) GUICtrlSetColor($c_label, 0xFFFFFF) GUICtrlSetBkColor($a_input, 0x000000) GUICtrlSetColor($a_input, 0xFFFFFF) GUICtrlSetBkColor($b_input, 0x000000) GUICtrlSetColor($b_input, 0xFFFFFF) GUICtrlSetBkColor($c_input, 0x000000) GUICtrlSetColor($c_input, 0xFFFFFF) GUICtrlSetColor($delta_box, 0xFFFFFF) GUICtrlSetColor($x1_box, 0xFFFFFF) GUICtrlSetColor($x2_box, 0xFFFFFF) GUICtrlSetColor($rad_delta_box, 0xFFFFFF) GUISetState()
Global $a, $b, $c, $delta, $rad_delta, $x1, $x2 Func delta() $a = GUICtrlRead($a_input) $b = GUICtrlRead($b_input) $c = GUICtrlRead($c_input) ;If $a==0 Then ;MsgBox(0, "Eroare", $a & " trebuie sa nu fie egal cu 0") ;Else If $b < 0 Then $b= $b* -1 If $c < 0 Then $c= $c* 1 $delta = ($b^2) - 4 * $a * $c $rad_delta = Round(Sqrt($delta), 1) ;If $delta < 0 Then MsgBox(0, "Eroare", "Delta este mai mic ca 0") GUICtrlSetData($delta_box, "Delta= " & $delta) GUICtrlSetData($rad_delta_box, "Rad. Delta= " & $rad_delta) ;EndIf EndFunc Func x1() $a = GUICtrlRead($a_input) $b = GUICtrlRead($b_input) $rad_delta = Sqrt($delta) $f = 2 * $a $ff = -$b + $rad_delta $x11 = $ff/$f $x1 = Round($x11, 1) GUICtrlSetData($x1_box, "x1= " & $x1) EndFunc
Func x2() $a = GUICtrlRead($a_input) $b = GUICtrlRead($b_input) $rad_delta = Sqrt($delta) $ff = 2 * $a $fff = -$b - $rad_delta $x22 = $fff/$ff $x2 = Round($x22, 1) GUICtrlSetData($x2_box, "x2= " & $x2) EndFunc
Func scrie() $rad_delta1 = Round(Sqrt($delta), 1) _FileCreate(@ScriptDir & "/rezolvare.txt") $file = FileOpen(@ScriptDir & "/rezolvare.txt", 1) FileWrite($file, $a & "x^2" & " + " & "(" & $b & ")" & "x" & " + " & "(" & $c & ")" & " = 0") FileWrite($file, @CRLF & @CRLF) FileWrite($file, "a = " & $a & @CRLF & "b = " & $b & @CRLF & "c = " & $c) FileWrite($file, @CRLF & @CRLF) FileWrite($file, "delta = b^2 - 4ac" & @CRLF) FileWrite($file, "delta = " & "(" & $b & ")" & "^2 - 4 * " & $a & " * " & "(" & $c & ")" & @CRLF) FileWrite($file, "delta = " & $delta) FileWrite($file, @CRLF & @CRLF) FileWrite($file, "x1,2 = -b +- radical din delta supra 2 * a" & @CRLF) FileWrite($file, "x1,2 = " & "-" & "(" & $b & ")" & " +- " & "radical " & $delta & " supra 2 * " & $a & @CRLF) FileWrite($file, "x1,2 = " & $b * -1 & " +- " & $rad_delta1 & " supra " & 2 * $a) FileWrite($file, @CRLF & @CRLF) FileWrite($file, "x1 = " & $b * -1 & " + " & $rad_delta1 & " supra " & 2 * $a & @CRLF) $num = ($b * -1) + $rad_delta1 $nr = 2 * $a $round1 = Round($num / $nr, 1) FileWrite($file, "x1 = " & Round($num, 1) & " supra " & $nr & @CRLF) FileWrite($file, "x1 = " & $round1) FileWrite($file, @CRLF & @CRLF) FileWrite($file, "x2 = " & $b * -1 & " - " & $rad_delta1 & " supra " & 2 * $a & @CRLF) $num1 = ($b * -1) - $rad_delta1 $nr1 = 2 * $a $round2 = Round($num1 / $nr1, 1) FileWrite($file, "x2 = " & Round($num1, 1) & " supra " & $nr1 & @CRLF) FileWrite($file, "x2 = " & $round2) FileWrite($file, @CRLF & @CRLF & @CRLF & @CRLF) FileWrite($file, "Legenda:" & @CRLF & @CRLF & " ^2 = la puterea 2") FileClose($file) EndFunc
Func s() $a = GUICtrlRead($a_input) $b = GUICtrlRead($b_input) $c = GUICtrlRead($c_input) If $b < 0 Then $b= $b* -1 If $c < 0 Then $c= $c* 1 $delta = ($b^2) - 4 * $a * $c If $a = 0 Then MsgBox(0, "Eroare!", "'a' nu trebuie sa fie egal cu 0") GUICtrlSetData($delta_box, "Delta=") GUICtrlSetData($x1_box, "x1=") GUICtrlSetData($x2_box, "x2=") ElseIf $delta < 0 Then MsgBox(0, "Eroare!", "'Delta' este mai mic ca 0") GUICtrlSetData($delta_box, "Delta=") GUICtrlSetData($x1_box, "x1=") GUICtrlSetData($x2_box, "x2=") Else delta() x1() x2() scrie() EndIf EndFunc While 1 $msg = GUIGetMsg() Select Case $msg = $reset GUICtrlSetData($delta_box, "Delta=") GUICtrlSetData($x1_box, "x1=") GUICtrlSetData($x2_box, "x2=") GUICtrlSetData($a_input, "") GUICtrlSetData($b_input, "") GUICtrlSetData($c_input, "") Case $msg = $calculate GUICtrlSetData($delta_box, "") GUICtrlSetData($x1_box, "") GUICtrlSetData($x2_box, "") s() Case $msg = $open If FileExists(@ScriptDir & "/rezolvare.txt") Then ShellExecute(@ScriptDir & "/rezolvare.txt") Else MsgBox(0, "Eroare!", "Fisierul 'rezolvare.txt' inca nu este creat!") EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd
@-Team
|
|
| |