19 April, 2012

writing award program and system testing argue most two hidden equations

13. writing award program and system testing argue most two hidden equations:


ax + by = c
a1x + b1y = c1
with the coefficients a, b, c, a1, b1, c1 is entered from the keyboard.


# include 
# include 
using namespace std;
void main ()
{
int a [3], b [3], * p, * q, dthuc;
int i;
float x, y;

cout << endl << "Enter the coefficients of the first equation:" << endl;
for (i = 0; i <= 2; i + +)
{
cout << "coefficient" << i +1 << ":";
cin >> a [i];
}
cout << endl << endl << "Enter the coefficients of the second equation:" << endl;
for (i = 0; i <= 2; i + +)
{
cout << "coefficient" << i +1 << ":";
cin >> b [i];
}
p = a;
q = b;

dthuc = (* q) * (* (p +1)) - (* p) * (* (q +1));
if (dthuc! = 0)
{
y = (float) ((* q) * (* (p +2)) - (* p) * (* (q +2))) / dthuc;
x = (float) ((* (q +2)) * (* (p +1)) - (* (p +2)) * (* (q +1))) / dthuc;
cout << "Nghiem x =" << x << "y =" << y;
}
else
cout << endl << "vo ngiem system of equations.";

getch ();
}

No comments:

Post a Comment

Thanks