Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- double a, b, c, x, y;
- printf("Moi nhap he so cua phuong trinh: ");
- scanf("%lf %lf %lf", &a, &b, &c);
- double denta = b*b - 4 * a*c;
- if (denta < 0)
- {
- printf("Phuong trinh vo nghiem");
- }
- else if (denta = 0)
- {
- y = -b / 2 * a;
- if (y >= 0){
- printf("k=2");
- printf("Phuong trinh co nghiem kep: x= %lf&& x= -%lf\n", x, x = sqrt(y), x = -sqrt(y));
- }
- else
- {
- printf("Phuong trinh vo nghiem\n");
- }
- }
- else
- {
- double y1, y2;
- y1 = (-b + sqrt(denta)) / 2 * a;
- y2 = (-b - sqrt(denta)) / 2 * a;
- if (y1 >= 0 && y2 >= 0)
- {
- printf("k=4");
- printf("Phuong trinh co 2 nghiem phan biet: x=%lf && x=%lf\n", x, x = sqrt(y1), x = -sqrt(y1));
- }
- else{
- printf("Phuong trinh vo nghiem");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement