IShatrov / Quadratic-Equation-Solver

Quadratic Equation Solver
0 stars 0 forks source link

Optimization #13

Open derzhavin3016 opened 2 years ago

derzhavin3016 commented 2 years ago

https://github.com/IShatrov/Quadratic-Equation-Solver/blob/c1f2bdf52e6d4e7e3d05b1fd920b4025e129fd08/quadratic_equation_solver/main.cpp#L81-L99

I think you can add here two cases:

  1. a != 0 && b == 0 => x = +- sqrt(c) (if c is not negative)
  2. a != 0 && c == 0 => x_1 = 0, x_2 = -b / a (zero root + linear equation)