-fixed gauss_down()

This commit is contained in:
Patrice Matz 2017-10-31 13:34:25 +01:00
parent 3bc8b5bd11
commit 1b07a149c5
3 changed files with 14 additions and 8 deletions

View File

@ -40,4 +40,5 @@ void lgs()
{
LGS lgs;
lgs.data_entry();
cout << lgs.gauss() << endl;
}

View File

@ -28,11 +28,10 @@ void LGS::data_entry()
cout << endl;
}
print();
cout << "Sind die angaben Korrekt? j/n "; cin >> auswahl;
cout << "Sind die Angaben Korrekt? j/n "; cin >> auswahl;
}
cout << endl;
gauss_down();
}
void LGS::creat_array()
@ -48,7 +47,7 @@ void LGS::print()
{
for (int n = 0; n < variables + 1; ++n)
{
cout << (GA[i][n] > 0 ? (n == 0 ? " " : " +") : " ") << GA[i][n] << " ";
cout << (GA[i][n] >= 0 ? (n == 0 ? " " : " +") : " ") << GA[i][n] << " ";
if (n == variables-1)
cout << "= ";
}
@ -61,7 +60,7 @@ void LGS::print_ln(int ln)
for (int n = 0; n < variables + 1; ++n)
{
int var = 123 - variables + n;
cout << (GA[ln][n] > 0 ? (n==0 ? " " : " +"): " ") << GA[ln][n] << (var!=123 ? (char)var : ' ');
cout << (GA[ln][n] >= 0 ? (n==0 ? " " : " +"): " ") << GA[ln][n] << (var!=123 ? (char)var : ' ');
if (n == variables - 1)
cout << "= ";
}
@ -76,7 +75,7 @@ void LGS::print_exp()
{
int var1 = n + 65;
int var2 = 123 - variables + n;
cout << "[" << (char)var1 << i + 1; var2!=123 ? cout<< (" *") : cout << ""; var2 != 123 ? cout << (char)var2 : cout << ""; cout << "]";
cout << "[" << (char)var1 << i + 1; var2!=123 ? cout<< (" *") << (char)var2 : cout << ""; cout << "]";
if (n == variables - 1)
cout << "= ";
}
@ -102,10 +101,10 @@ float LGS::gauss()
void LGS::gauss_down( )
{
for(int stage = 1; stage < (variables==2 ? variables : variables-1) ; stage++)
for(int stage = 1; stage < variables ; stage++)
{
long double div = (GA[stage][stage-1] / GA[stage-1][stage-1]);
for (int i = 0; i < variables-1; i++)
for (int i = 0; i < variables-1 && stage+i < variables; i++)
{
for (int n = 0; n <= variables; n++)
{
@ -121,6 +120,12 @@ void LGS::gauss_down( )
}
void LGS::gauss_up()
{
}

View File

@ -21,5 +21,5 @@ public:
void print_ln(int);
void print_exp();
void gauss_down();
void gauss_up(){};
void gauss_up();
};