Last active
March 13, 2016 16:47
-
-
Save ataias/b8f9043cb46285ccd5ee to your computer and use it in GitHub Desktop.
Bhaskara formula
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cmath> | |
bool is_nan(double x) { return x != x; } | |
using namespace std; | |
int main() { | |
double A, B, C; | |
scanf("%lf", &A); | |
scanf("%lf", &B); | |
scanf("%lf", &C); | |
double delta = sqrt(B*B - 4*A*C); | |
if(is_nan(delta) || A == 0.0){ | |
printf("Impossivel calcular\n"); | |
return 0; | |
} | |
double r1 = (-B + delta)/(2*A); | |
double r2 = (-B - delta)/(2*A); | |
printf("R1 = %.5f\n", r1); | |
printf("R2 = %.5f\n", r2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason, the first version is not getting correctly compile on URI. I am trying to discover why.