Created
February 16, 2022 06:30
-
-
Save asonnleitner/f577cbc06d0ce8c0f8f2b8538e33eba9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Zadejte a, b, c" | |
a = gets.chomp.to_f # konverze na float | |
b = gets.chomp.to_f | |
c = gets.chomp.to_f | |
# Výpočet diskriminantu | |
DIS = b**2 - 4 * a * c | |
puts "Diskriminant je #{DIS}" | |
if DIS > 0 | |
x1 = (-b + (DIS**0.5)) / (2 * a) | |
# nebo (-b + Math.sqrt(DIS)) / (2 * a) | |
x2 = (-b - (DIS**0.5)) / (2 * a) | |
# nebo (-b - Math.sqrt(DIS)) / (2 * a) | |
puts "x1: #{x1}, x2: #{x2}" | |
elsif DIS == 0 | |
x = -b / (2 * a) | |
puts "x = #{x}" | |
else | |
puts "Rovnice nemá řešení" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment