andreitrane
Новичок
- Сообщения
- 141
- Репутация
- 3
почему не хочет решать квадратные уравнения?
например ввожу этот
2Х^2+5Х-25
ответ на него Х1=-5 и Х=2,5
но программа отвечает что нет решения
что надо исправить?
например ввожу этот
2Х^2+5Х-25
ответ на него Х1=-5 и Х=2,5
но программа отвечает что нет решения
что надо исправить?
Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Рабочий стол\БОТ!!!\формы ботов\квадратное уравнение.kxf
$kvur = GUICreate("Квадратное уравнение", 302, 65, 362, 336)
$ainput = GUICtrlCreateInput("", 8, 8, 57, 21)
$Label1 = GUICtrlCreateLabel("Х", 64, 8, 16, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label2 = GUICtrlCreateLabel("2", 80, 0, 11, 17)
GUICtrlSetFont(-1, 2, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$binput = GUICtrlCreateInput("", 88, 8, 49, 21)
$Label3 = GUICtrlCreateLabel("Х", 136, 8, 16, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$cinput = GUICtrlCreateInput("", 152, 8, 57, 21)
$Label4 = GUICtrlCreateLabel("=", 208, 8, 16, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$otvet = GUICtrlCreateInput("", 224, 8, 65, 21)
$startpr = GUICtrlCreateButton("Вычислить", 8, 40, 89, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $startpr
$a = GUICtrlRead($ainput)
$b = GUICtrlRead($binput)
$c = GUICtrlRead($cinput)
$d = $b*$b+4*$a*$c
if Number($d) < Number(0) Then
MsgBox(0, "", "нет решений")
ElseIf Number($d) = Number(0) Then
$x = (-$b)/2*$a
GUICtrlSetData($otvet, $x)
Else
$x1 = ((-$b)-Sqrt($d))/2*$a
$x2 = ((-$b)+Sqrt($d))/2*$a
GUICtrlSetData($otvet, $x1 &"; "& $x2)
EndIf
EndSwitch
WEnd