Advertisement
huutho_96

Untitled

Mar 12th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. double a, b, c, x, y;
  6. printf("Moi nhap he so cua phuong trinh: ");
  7. scanf("%lf %lf %lf", &a, &b, &c);
  8. double denta = b*b - 4 * a*c;
  9. if (denta < 0)
  10. {
  11. printf("Phuong trinh vo nghiem");
  12. }
  13. else if (denta = 0)
  14. {
  15. y = -b / 2 * a;
  16. if (y >= 0){
  17. printf("k=2");
  18. printf("Phuong trinh co nghiem kep: x= %lf&& x= -%lf\n", x, x = sqrt(y), x = -sqrt(y));
  19. }
  20. else
  21. {
  22. printf("Phuong trinh vo nghiem\n");
  23. }
  24. }
  25. else
  26. {
  27. double y1, y2;
  28. y1 = (-b + sqrt(denta)) / 2 * a;
  29. y2 = (-b - sqrt(denta)) / 2 * a;
  30. if (y1 >= 0 && y2 >= 0)
  31. {
  32. printf("k=4");
  33. printf("Phuong trinh co 2 nghiem phan biet: x=%lf && x=%lf\n", x, x = sqrt(y1), x = -sqrt(y1));
  34. }
  35. else{
  36. printf("Phuong trinh vo nghiem");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement