Advertisement
roronoa

second degré

Apr 25th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. void main()
  2. {
  3. int a,b,c,d;
  4. scanf("%d%d%d",&a,&b,&c);
  5. d=b*b-4*a*c;
  6. if(d>0)
  7. {
  8. double x=(-1*b-sqrt(d))/(2*a),y=(-1*b+sqrt(d))/(2*a);
  9. int k=(int)x,l=(int)y;
  10.  if(x<y){
  11.         if(k-x==0)printf("%d ",k);
  12.         else printf("%.1f ",x);
  13.         if(l-y==0)printf("%d",l);
  14.         else printf("%.1f",y);}
  15.         else
  16.         {
  17.             if(l-y==0)printf("%d ",l);
  18.         else printf("%.1f ",y);
  19.         if(k-x==0)printf("%d",k);
  20.         else printf("%.1f",x);
  21.         }
  22.     }
  23.     if(d<0)printf("No real solutions");
  24.     if(d==0)
  25.     { double x=(-1*b)/(2*a);int z=(int)x;if(x-z==0)printf("%d",z);else printf("%.1f",x);}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement