Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //911. Квадратное уравнение
- //zadacha from e-olimp
- #include<iostream>
- #include<cmath>
- #include<cstdlib>
- #include<cstdio>
- using namespace std;
- int main()
- {
- int a,b,c,x1,x2;
- double d;
- cin>>a>>b>>c;
- d=b*b - 4 * a * c;
- x1=(-b + sqrt(d)) / 2 * a;
- x2=(-b - sqrt(d)) / 2 * a;
- if (d < 0) {cout<<"No roots"<<endl; exit(0);}
- if (d == 0) {cout<<"One root:"<<" "<<x1<<endl; exit(0);}
- if (d > 0) {
- if (x1 < x2) {cout<<"Two roots:"<<" "<<x1<<" "<<x2<<endl; exit(0);}
- if (x1 >= x2) {cout<<"Two roots:"<<" "<<x2<<" "<<x1<<endl; exit(0);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement