Квадратное уравнение в Clarion
Пример для версий
Clarion C7
минималистическая версия
PROGRAM
OMIT('***')
* User: Shur
* Date: 28.02.2016
* Time: 14:05
***
MAP
END
A REAL
B REAL
C REAL
root CSTRING(64)
CODE
A=0; B=2; C=3
!A=1; B=-5; C=3
!A=1; B=2; C=1
D$ = B * B - 4 * A * C
if A = 0
root = 'Not a quadratic equation.'
elsif D$ = 0
root = 'x = ' & -B/2/A
elsif D$ > 0 then
root = 'x1 = ' & (-B-sqrt(D$))/2/A & '|' & |
'x2 = ' & (-B+sqrt(D$))/2/A
else
root = 'x1 = (' & -B/2/A & ', ' & sqrt(-D$)/2/A & ')' & '|' & |
'x2 = (' & -B/2/A & ', ' & -sqrt(-D$)/2/A & ')'
end
message(choose(A=0,'','D='&D$&'|----------|')&root,'Quadratic equation')
Комментарии
]]>blog comments powered by Disqus
]]>