Ich habe mir heute in der Schule gedacht man kann doch sicher ein Programm erstellen welches in eine Formel mit einer Variablen eine Belibige Zahlenfolge einsetzt und irgendwann müsste das richtige Ergebnis ja dabei sein. Das habe ich auch versucht nur scheine ich irgendwo einen Fehler gemacht zuhaben da er mir immer auspuckt das die Lösung 0.01 ist jemand eine Idee?
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$z = 0 ;Wert der Test Zahl
$ergebnis = "nicht null"
#Region ### START Koda GUI section ### Form=
$Form1_1_1 = GUICreate("Variablen Rechner für Mathe", 381, 197, 192, 124)
$links = GUICtrlCreateInput("", 8, 32, 169, 21)
$Label1 = GUICtrlCreateLabel("Formel", 160, 8, 59, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$help = GUICtrlCreateButton("Hilfe", 280, 56, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Suche", 32, 88, 55, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Ergebnis", 32, 136, 75, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$start = GUICtrlCreateButton("Start", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Lable = GUICtrlCreateLabel("Getestete Zahlen", 272, 88, 91, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Serif")
$ergebnis = GUICtrlCreateLabel("", 32, 160, 80, 30)
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$rechts = GUICtrlCreateInput("", 208, 32, 169, 21)
$Label2 = GUICtrlCreateLabel("=", 184, 24, 16, 30)
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $start
_los()
EndSwitch
WEnd
Func _los()
While 1
$z = $z + 0.01
$linksgelesen = GUICtrlRead($links)
$rechtsgelesen = GUICtrlRead($rechts)
$linksreplace = StringReplace($linksgelesen, "x", $z)
$rechtsreplace = StringReplace($rechtsgelesen, "x", $z)
$linksexe=Execute(GUICtrlRead($linksreplace))
$rechtsexe=Execute(GUICtrlRead($rechtsreplace))
GUICtrlSetData($links,$linksexe)
GUICtrlSetData($rechts,$rechtsexe)
$ergebnis = $linksexe - $rechtsexe
If $ergebnis = 0 Then
MsgBox(0, "", "Die Lösung ist " & $z & ".")
ExitLoop
EndIf
$1 = StringReplace($linksreplace, $z, "x")
$2 = StringReplace($rechtsreplace, $z, "x")
GUICtrlSetData($links,$1)
GUICtrlSetData($rechts,$2)
WEnd
EndFunc ;==>_los