fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. // giải hệ phương trình bậc 2:
  5. int main()
  6. {
  7. float a,b,c,d,e,f,D,Dx,Dy;
  8. printf("Nhap vao he so a,b,c : ");
  9. scanf("%f%f%f",&a,&b,&c);
  10. printf("Nhap vao he so d,e,f : ");
  11. scanf("%f%f%f",&d,&e,&f);
  12. D = a*e - b*d;
  13. Dx = c*e - b*f;
  14. Dy = a*f - c*d;
  15. if(D != 0)
  16. printf("=> he phuong trinh co nghiem duy nhat :\n x = %.3f\n y = %.3f",Dx/D,Dy/D);
  17. else{
  18. if(Dx == 0 && Dy == 0)
  19. printf("=> he phuong trinh co vo so nhiem.");
  20. else
  21. printf("=> he phuong trinh vo nghiem.");
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 10320KB
stdin
1 2 3
3 4 5
stdout
Nhap vao he so a,b,c : Nhap vao he so d,e,f : => he phuong trinh co nghiem duy nhat :
 x = -1.000
 y = 2.000