#include
#include
void main()
{
float a11, a12, a13, a21, a22, a23, a31, a32, a33, b1, b2, b3, x, y, z, d, dx, dy, dz;
printf("nhap cac he so phuong trinh 1:\n");
scanf_s("%f%f%f%f", &a11, &a12, &a13, &b1);
printf("nhap cac he so phuong trinh 2:\n");
scanf_s("%f%f%f%f", &a21, &a22, &a23, &b2);
printf("nhap cac he so phuong trinh 3:\n");
scanf_s("%f%f%f%f", &a31, &a32, &a33, &b3);
d = a11*a22*a33 + a12*a23*a31 + a21*a32*a13 - a13*a22*a31 - a12*a21*a33 - a11*a32*a23;
dx = b1*a22*a33 + a12*a23*b3 + b2*a32*a13 - a13*a22*b3 - a12*b2*a33 - a23*a32*b1;
dy = a11*b2*a33 + b1*a23*a31 + a21*b3*a13 - a13*b2*a31 - b1*a21*a33 - a23*b3*a11;
dz = a11*a22*b3 + a12*b2*a31 + a21*a32*b1 - b1*a22*a31 - a12*a21*b3 - b2*a32*a11;
if (d == 0)
{
if ((dx == 0) && (dy == 0) && (dz == 0))
printf("he vo so nghiem");
else printf("he vo nghiem");
}
else
{
printf("he co nghiem la:\n x=%.2f \n y=%.2f \n z=%.2f", dx / d, dy / d, dz / d);
}
_getch();
}
0 nhận xét:
Đăng nhận xét