1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void solveEquation(double,double,double,double,double,double,double &,double &, bool &);
bool isSolvable(double a, double b,double c,double d)
{
if ((a*d)-(b*c) == 0)
{return true;}
else
return true;
}
void solveEquation(double a, double b, double c, double d, double e, double f, double &x, double &y, bool &isSolvable)
{
x = (e*d - b* f)/(a*d - b*c);
y = (a*f - e* c)/(a*d-b*c);
}
int main ()
{
double a;
double b;
double c;
double d;
double e;
double f;
double x;
double y;
double g;
bool isSolvable;
cout << "Enter a, b, c, d, e, f: ";
cin >> a;
cin>> b;
cin >> c;
cin >> d;
cin >> e;
cin >> f;
solveEquation(a,b,c,d,e,f,x,y, isSolvable);
cout << fixed << setprecision(1) << "x is " << x << " and y is " << y << endl;
}
|