mirror of https://github.com/Askill/AP-SCE.git
- added ui/data entry for LGS
- added matrix output - TODO: implement gauß and cramer
This commit is contained in:
parent
75b22db2b3
commit
a0e91b0365
|
|
@ -1 +1,6 @@
|
|||
#include "2d.h"
|
||||
|
||||
long double Circle::compute_area(long double d)
|
||||
{
|
||||
return (d / 2)*(d / 2) * 3.14159265359;
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ void Cylinder::data_entry()
|
|||
cout << "Definieren Sie die Teilabschnitte des Zylinders" << endl;
|
||||
cout << " Laenge in mm: "; cin >> teil_lange; heights.push_back(teil_lange);
|
||||
cout << " Durchmesser in mm: "; cin >> teil_durchmesser; radii.push_back(teil_durchmesser);
|
||||
cout << " Dichte in g/mm^3: "; cin >> teil_dichte; densities.push_back(teil_dichte);
|
||||
cout << " Dichte in g/cm^3: "; cin >> teil_dichte; densities.push_back(teil_dichte);
|
||||
cout << " Spezifischer Widerstand in ohm * (mm^2) / m: "; cin >> teil_widerstand; resistances.push_back(teil_widerstand);
|
||||
cout << " Gibt es weitere Teilbereiche? j/n "; cin >> auswahl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#include "3d.h"
|
||||
#include <iostream>
|
||||
#include "lgs.h"
|
||||
using namespace std;
|
||||
|
||||
void cylinder();
|
||||
void lgs();
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -11,6 +13,7 @@ int main()
|
|||
{
|
||||
cout << "Was wollen Sie tun ?" << endl;
|
||||
cout << "1 Berechungen an einem Zylinder" << endl;
|
||||
cout << "2 LGS lösen" << endl;
|
||||
|
||||
cout << "e Beenden" << endl;
|
||||
|
||||
|
|
@ -18,6 +21,7 @@ int main()
|
|||
switch(auswahl)
|
||||
{
|
||||
case '1': cylinder(); break;
|
||||
case '2': lgs(); break;
|
||||
|
||||
default: cout << "Okay, bye" << endl; break;
|
||||
}
|
||||
|
|
@ -32,3 +36,8 @@ void cylinder()
|
|||
cylinder.compute_options();
|
||||
|
||||
}
|
||||
void lgs()
|
||||
{
|
||||
LGS lgs;
|
||||
lgs.data_entry();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
#include "lgs.h"
|
||||
#include "time.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
void LGS::data_entry()
|
||||
{
|
||||
char auswahl = 'n';
|
||||
//Data entry
|
||||
while (auswahl == 'n')
|
||||
{
|
||||
cout << "Anzahl der Unbekannten: "; cin >> variables;
|
||||
creat_array();
|
||||
cout << "Geben Sie die Gleichungen nach folgendem Schema an:" << endl;
|
||||
cout << "[A1 *x][B1 *y][C1 *z]=[D1]" << endl;
|
||||
cout << "[A2 *x][B2 *y][C2 *z]=[D2]" << endl;
|
||||
cout << "[A3 *x][B3 *y][C3 *z]=[D3]" << endl;
|
||||
|
||||
for (int i = 0; i < variables; ++i)
|
||||
{
|
||||
for (int n = 0; n < variables+1; ++n)
|
||||
{
|
||||
cout << " ";
|
||||
int var = n + 65;
|
||||
cout << (char)var << i + 1 << ": ";
|
||||
cin >> GA[i][n];
|
||||
|
||||
}
|
||||
print_ln(i);
|
||||
cout << endl;
|
||||
}
|
||||
print();
|
||||
cout << "Sind die angaben Korrekt? j/n"; cin >> auswahl;
|
||||
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
}
|
||||
|
||||
void LGS::creat_array()
|
||||
{
|
||||
GA = new long double*[variables];
|
||||
for (int i = 0; i < variables; ++i)
|
||||
GA[i] = new long double[variables+1];
|
||||
}
|
||||
|
||||
void LGS::print()
|
||||
{
|
||||
for (int i = 0; i < variables; ++i)
|
||||
{
|
||||
for (int n = 0; n < variables + 1; ++n)
|
||||
{
|
||||
cout << GA[i][n] << " ";
|
||||
if (n == variables-1)
|
||||
cout << "= ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void LGS::print_ln(int ln)
|
||||
{
|
||||
for (int n = 0; n < variables + 1; ++n)
|
||||
{
|
||||
int var = 123 - variables + n;
|
||||
cout << " +" << GA[ln][n] << (var!=123 ? (char)var : ' ');
|
||||
if (n == variables - 1)
|
||||
cout << "= ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
float LGS::cramer()
|
||||
{
|
||||
double t1 = clock();
|
||||
|
||||
return (float)((clock() - t1) / CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
float LGS::gauss()
|
||||
{
|
||||
double t1 = clock();
|
||||
|
||||
return (float)((clock() - t1) / CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
class LGS{
|
||||
public:
|
||||
long double** GA;
|
||||
int variables = 0;
|
||||
|
||||
|
||||
LGS(){};
|
||||
~LGS()
|
||||
{
|
||||
for (int i = 0; i < variables; ++i)
|
||||
delete[] GA[i];
|
||||
delete[] GA;
|
||||
};
|
||||
|
||||
float gauss();
|
||||
float cramer();
|
||||
void data_entry();
|
||||
void creat_array();
|
||||
void print();
|
||||
void print_ln(int);
|
||||
};
|
||||
Loading…
Reference in New Issue