Advertisement
artur99

Untitled

Jul 28th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int a, b, c;
  10.     double disc, x1, x2;
  11.     string res;
  12.     cout << "a="; cin >> a;
  13.     cout << "\nb="; cin >> b;
  14.     cout << "\nc="; cin >> c;
  15.  
  16.     disc = b*b - 4 * a*c;
  17.  
  18.     if (disc < 0){
  19.         cout << "Nu are solutii in multimea numerelor reale.";
  20.     }
  21.     else{
  22.         x1 = (-b + sqrt(disc)) / (2 * a);
  23.         x2 = (-b - sqrt(disc)) / (2 * a);
  24.         res = "Solutiile sunt " + to_string(x1) + " si " + to_string(x2) + ".";
  25.         cout << res;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement