Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<Iostream>
- #include<cmath>
- #include<iomanip>
- using namespace std;
- int main(){
- long long int a, b, c;
- long double x1, x2;
- cin >> a >> b >> c;
- if(c == 0){
- x1 = 0;
- x2 = -1*b/a;
- }
- else if(b > abs(a*c)){
- x1 = (-b - sqrt(b*b - 4*a*c)) / (2*a);
- x2 = c / (a*x1);
- }
- else{
- x1 = (-b + sqrt(b*b - 4*a*c)) / (2*a);
- x2 = c / (a*x1);
- }
- cout << "x1 = " << x1 << endl;
- cout << "x2 = " << x2 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement