Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- cout << "Risolutore equazioni di secondo grado" << endl;
- cout << "Inserire A: " << endl;
- int a;
- cin >> a;
- cout << "Inserire B: " << endl;
- int b;
- cin >> b;
- cout << "Inserire C: " << endl;
- int c;
- cin >> c;
- double delta = pow(b, 2) - 4 * a * c;
- double sqrt_delta = pow(delta, 0.5);
- if (delta == 0) {
- int x1;
- x1 = -b / 2 * a;
- cout << "x = " << x1 << endl;
- } else if (delta < 0) {
- cout << "L'equazione non ha soluzioni" << endl;
- } else {
- int x1, x2;
- x1 = (-b + sqrt_delta) / (2 * a);
- x2 = (-b - sqrt_delta) / (2 * a);
- cout << "x1 = " << x1 << endl;
- cout << "x2 = " << x2 << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment