我目前正在尝试创建一个可以解决联立方程的程序。我有这个:
int main()
{ float a1,a2,b1,b2,c1,c2;
float x,y;
system("CLS");
printf("We require simultaneous in the form of \n\n\ta1x+b1y=c1\n\n\ta2x+b2y=c2\n");
printf("enter the values of a1,b1,c1 \n a2,b2,c2\n respectively:\n");
scanf("%f%f%f%f%f%f",&a1,&b1,&c1,&a2,&b2,&c2);
printf("The Simultaneous equations are \n %fx+%fy=%f",a1,b1,c1);
printf("and\n%fx+%fy=%f",a2,b2,c2);
printf("\n\nThe Solution is=\n");
y=(((c1*a2)-(c2*a1))/((b1*a2)-(a1*b2)));
x=((c1-(b1*y))/a1);
printf(" x = %f",x);
printf("\n y = %f",y);
_getch();
return 0;
}
它按我的预期工作,但是,我不理解 and 的算法y
,x
谁能给我另一个代码或解释我在这里的当前代码?