Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int a,b,c,d=0,x1=0,x2=0;
- cin >> a >> b >> c;
- d=b*b-(4*a*c);
- if (d<0) {
- cout << "No roots";
- return 0;
- }
- if (d==0) {
- x1=(-b)/2*a;
- cout << "One root:" << " " << x1;
- return 0;
- }
- if (d!=0) {
- x1=(-b+sqrt(d))/(2*a);
- x2=(-b-sqrt(d))/(2*a);
- cout << "Two roots:" << " " << min(x1,x2) << " " << max(x1,x2);
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment