前往
大廳
主題

C/C++紀錄七.<<簡單寫二元一次聯立方程>> 2018/8/7

艾倫D索妮雅 | 2021-06-07 22:50:17 | 巴幣 0 | 人氣 3106


#include<iostream>
#include<cstdlib>
#include<cmath>
//簡單寫解二元一次聯立方程式//
using namespace std;
int main()
{
int a,b,c;
int d,e,f;
double x,y,det;
cout<<"解二元一次聯立ax+by=c"<<endl;
cout<<"              dx+ey=f"<<endl;
cout<<"請輸入a、b、c、d、e、f之值"<<endl;
cin>>a>>b>>c>>d>>e>>f;
det=a*e-d*b;
x=(c*e-b*f)/det;
y=(-d*c+a*f)/det;
cout<<"您的解答為:"<<endl;
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
return 0;
}

創作回應

更多創作