Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- float a,b,c,x1,x2,d,pd,z;
- char L;
- int main()
- {
- scanf ("%f %f %f", &a, &b, &c);
- kwadratowa ();
- return 0;
- }
- void kwadratowa ()
- {
- if (a==0 && b==0 && c==0)
- {
- printf("R");
- return 0;
- }
- if (a==0 && b==0)
- {
- printf("0");
- return 0;
- }
- if (a!=0)
- {
- d=(b*b)-(4*a*c);
- pd=sqrt(d);
- x1=(-b-pd)/(2*a);
- x2=(-b+pd)/(2*a);
- if (d>0)
- {
- L='2';
- if (x1>x2)
- {
- z=x1;
- x1=x2;
- x2=z;
- }
- printf("%c %.1f %.1f", L, x1, x2);
- }
- if (d<0)
- {
- L='R';
- printf("%c", L);
- }
- if (d==0)
- {
- L='1';
- printf("%c %.1f", L, x1);
- }
- }
- else
- {
- x1= -c/b;
- L='1';
- printf ("%c %.1f", L, x1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement