Skip to content

Instantly share code, notes, and snippets.

@TheoKlein
Last active February 27, 2016 03:30
Show Gist options
  • Select an option

  • Save TheoKlein/ded78020d5ed843e1cf7 to your computer and use it in GitHub Desktop.

Select an option

Save TheoKlein/ded78020d5ed843e1cf7 to your computer and use it in GitHub Desktop.
ZeroJudge_a006_C
#include <stdio.h>
#include <math.h>
int main (){
int a,b,c;
int x = 0, y = 0;
while(scanf("%d%d%d",&a,&b,&c)!= EOF){
if (b*b-(4*a*c) > 0){
x = ((-b) + sqrt(b*b-(4*a*c)))/(2*a);
y = ((-b) - sqrt(b*b-(4*a*c)))/(2*a);
printf("Two different roots x1=%d , x2=%d\n",x,y);
}
else if (b*b-(4*a*c) == 0){
x = ((-b) + sqrt(b*b-(4*a*c)))/(2*a);
printf("Two same roots x=%d\n",x);
}else
printf("No real root\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment