Array 2 Dimensional much in use to create a matrix or table data, while the one-dimensional Array in use to make the results or data that berkoordinat X only. In this post two-dimensional array in use to accommodate the values of a component of mathematical equations. While one-dimensional Array used to hold the result or the value of the equation.
# Include
# Include
using namespace std;
class xyz {/ / declaring class xyz
public: / /deklaration function xyz, enter, process and exit
xyz ();
void enter ();
void process ();
void exit ();
private: / / declaring variables a, b and x, y, z
float a [3] [3];
float b [3];
float x, y, z;
};
xyz:: xyz () {/ / pendeskripsian function xyz
court <
court <<"Looking for Value x, y, z from Equation 3 \ n \ n";
}
void xyz:: get () {/ / entry function pendeskripsian
for (int i = 0; i <3; i + +) {
court <<"Equal to" <<<":"<< endl;
court <<"component x:";
cin>> a [i] [0]; / / insert the value x of an equation
court <<"y components:";
cin>> a [i] [1]; / / insert the value y of an equation
court <<"z components:";
cin>> a [i] [2]; / / insert the value z of an equation
court <<"result:";
cin>> b [i]; / / insert the equation from an equation
court <
}
/ / Display the equation
court <<"\ nPersamaaan:" <
for (int i = 0; i <3; i + +) {
court <<<"x +" <<<"y +" <<<"z =" <<
}
void xyz:: process () {/ / declaring the function of the process
for (int i = 1; i> 0; i -) {/ / loop starts from i = 1 until i> 0
for (int j = 0; j <= 2; j + +) {
a [i] [j] = a [i] [j] - a [i-1] [j]; / / scoring a
}
}
for (int i = 2; i> 1; i -) {/ / loop starts from i = 2 to i> 1
for (int j = 0; j <= 2; j + +) {
a [i] [j] = a [i] [j] - a [i-2] [j];
}
}
for (int i = 2; i> 1; i -) {/ / loop starts from i = 2 to i> 1
for (int j = 0; j <= 2; j + +) {
a [i] [j] = a [i] [j] - (2 * a [i-1] [j]);
}
}
b [1] = b [1] - b [0]; / / assignment b
b [2] = b [2] - b [0];
b [2] = b [2] - (2 * b [1]);
z = b [2] / a [2] [2]; / / assignment to the variable z
y = b [1] - (a [1] [2] * z); / / assignment to the variable y
x = b [0] - (a [0] [1] * y) - (a [0] [2] * z); / / assignment to the variables x
}
void xyz:: exit () {/ / exit function pendeskripsian
court <
court <<"The value of x =" <<
court <<"The value y =" <<
court <<"The value of z =" <<
court <<
}
int main (int argc, char * argv [])
{
xyz a;
a.masuk ();
a.proses ();
a.keluar ();
system ("PAUSE");
return EXIT_SUCCESS;
}
0 comments:
Posting Komentar