(1) determine whether a is zero,
(2) calculate the discriminant,
(3) calculate root,
(4) the output root,
CodePudding user response:
Can be used for root companyCodePudding user response:
# include
#include
using namespace std;
//return the number of solutions
Int solve (double a, b double, double c) {
//determine whether a 0
If (a==0) {
Cout<& lt;" Solution: "& lt; <- c/breturn 1;
}
The else {
Int Jugement=SQRT (* a * b * b - 4 c);
If (Jugement> 0 {
Cout<& lt;" Solution: "& lt; <(Jugement - b)/(2 * a) & lt; & lt;" And "& lt; <(Jugement - b)/(2 * a) & lt;Return 2;
}
Else if (Jugement==0) {
Cout<& lt;" Solution: "& lt; <(Jugement - b)/(2 * a) & lt;return 1;
}
The else {
return 0;
}
}
}
Int main () {
Double a, b, c;
Cout<& lt;" Please enter a, b, c value: ";
cin> A> B> c;
Int result=solve (a, b, c);
Cout<& lt;" Equation has "& lt;return 0;
}