Skip to content

Instantly share code, notes, and snippets.

@ataias
Last active March 13, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ataias/b8f9043cb46285ccd5ee to your computer and use it in GitHub Desktop.
Save ataias/b8f9043cb46285ccd5ee to your computer and use it in GitHub Desktop.
Bhaskara formula
#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;
}
@ataias
Copy link
Author

ataias commented Mar 13, 2016

For some reason, the first version is not getting correctly compile on URI. I am trying to discover why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment