Open derzhavin3016 opened 2 years ago
https://github.com/IShatrov/Quadratic-Equation-Solver/blob/c1f2bdf52e6d4e7e3d05b1fd920b4025e129fd08/quadratic_equation_solver/main.cpp#L81-L103
I think that you can make this code look much simpler if you do like this (pseudocode):
if (a == 0) return solve_linear(); // solve real quadric
The main point here is that you can omit else clause if you have a return in corresponding if. So if you have a construction:
else
return
if
if (!something) { // perform some actions } else return 0;
You can rewrite it:
if (something) return 0; // perform some actions
Looks much simpler, isn't it?
https://github.com/IShatrov/Quadratic-Equation-Solver/blob/c1f2bdf52e6d4e7e3d05b1fd920b4025e129fd08/quadratic_equation_solver/main.cpp#L81-L103
I think that you can make this code look much simpler if you do like this (pseudocode):
The main point here is that you can omit
else
clause if you have areturn
in correspondingif
. So if you have a construction:You can rewrite it:
Looks much simpler, isn't it?