Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Roots-of-a-function/PureBasic/roots-of-a-function.basic
Normal file
28
Task/Roots-of-a-function/PureBasic/roots-of-a-function.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
Procedure.d f(x.d)
|
||||
ProcedureReturn x*x*x-3*x*x+2*x
|
||||
EndProcedure
|
||||
|
||||
Procedure main()
|
||||
OpenConsole()
|
||||
Define.d StepSize= 0.001
|
||||
Define.d Start=-1, stop=3
|
||||
Define.d value=f(start), x=start
|
||||
Define.i oldsign=Sign(value)
|
||||
|
||||
If value=0
|
||||
PrintN("Root found at "+StrF(start))
|
||||
EndIf
|
||||
|
||||
While x<=stop
|
||||
value=f(x)
|
||||
If Sign(value) <> oldsign
|
||||
PrintN("Root found near "+StrF(x))
|
||||
ElseIf value = 0
|
||||
PrintN("Root found at "+StrF(x))
|
||||
EndIf
|
||||
oldsign=Sign(value)
|
||||
x+StepSize
|
||||
Wend
|
||||
EndProcedure
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue