Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/gcl -f
- (defun printResult ( a b c x)
- (let
- (
- (bSign "+")
- (cSign "+")
- )
- (if (< b 0) (setf bSign "") ())
- (if (< c 0) (setf cSign "") ())
- (format t
- "For ~A*x^2 ~A ~A*x ~A ~A = 0 You can find ~A.~%"
- a
- bSign b
- cSign c
- x
- )
- )
- )
- (defun calcX (a b c)
- (let
- (
- (d 0)
- (x 0)
- )
- (setf d (- (* b b) (* 4 a c)))
- (if (> d 0)
- (setq x
- (list
- ( /
- (+ b (sqrt d))
- (* 2 a)
- )
- ( /
- (- b (sqrt d))
- (* 2 a)
- )
- )
- )
- (if (eql d 0)
- (setq x
- (list
- (/
- (- b)
- (* 2 a)
- )
- )
- )
- (setq x () )
- )
- )
- x
- )
- )
- (defun square ()
- (format t "a*x^2 + b*x + c = 0~%")
- (let
- (
- (a 0)
- (b 0)
- (c 0)
- (x 0)
- )
- (format t "a=")
- (setf a (read))
- (format t "b=")
- (setf b (read))
- (format t "c=")
- (setf c (read))
- (setf x (calcX a b c))
- (printResult a b c x)
- )
- )
- (square)
- (bye)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement