Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Giai phuong trinh ax^2 + bx + c =0
- // Khai bao cac thu vien
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- void main()
- {
- int a,b,c;
- scanf("%d%d%d",&a,&b,&c);
- if(a==0)
- {
- if(b==0)
- {
- if(c==0)
- {
- printf("PT co nghiem tuy y");
- }
- else
- {
- printf(" PT vo nghiem");
- }
- }
- else
- {
- printf("PT co nghiem duy nhat: %.2f", (float) -b/a);
- }
- }
- else
- {
- float delta =(float) (b*b) -(4*a*c) ;
- if(delta <0)
- {
- printf(" PT vo nghiem");
- }
- else
- {
- if(delta==0)
- {
- printf(" PT co nghiem kep x1=x2 : %.2f", (float) -b/(2*a));
- }
- else
- {
- float x1=(float)(-b +sqrt(delta))/(2*a);
- float x2=(float)(-b - sqrt(delta))/(2*a);
- printf("PT co 2 nghiem phan biet: x1= %.2f\n, x2=%.2f\n", x1,x2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement