我目前正在尝试创建一个可以求解联立方程的程序。我有这个:
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;
}
Run Code Online (Sandbox Code Playgroud)
而且它的工作如我所料,但我不明白的算法y和x,谁能给我一个代码或解释目前的代码,我在这里?
| 归档时间: |
|
| 查看次数: |
3806 次 |
| 最近记录: |