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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include <iostream>
using namespace std;
class Tobi
{
private:
int Kons1;
int Kons2;
int RT;
int IT;
public:
Tobi(int k1,int k2) // Deklaration und Definition Konstruktor
{
Kons1 = k1;
Kons2 = k2;
};
void add(int& rt, int& it)
{
rt += Kons1;
it += Kons2;
}
void sub(int& rt, int& it)
{
rt = Kons1 - rt; // Kons1 = a & rt = c
it = Kons2 - it; // Kons2 = b & it = d
}
void mul(int& rt, int& it)
{
rt = ((Kons1 * rt) - (Kons2 * it));
it = ((Kons2 * rt) + (Kons1 * it));
}
void div(int& rt, int& it)
{
float c; // Not sure if my typecasting is correct!
c = int (rt);// Not even sure if this is allowed.
float d; // Anyway, the result that I get is not correct.
d = int (it);
float a;
a = int (Kons1);
float b;
b = int (Kons2);
c = ((a * c) + (b * d)) / (( c * c) + (d * d));
d = ((b * c) - (a * d)) / (( c * c) + (d * d));
}
};
int main()
{
int x, y;
char z;
cin >> x;
cin >> y;
cin >> z;
Tobi v1(1,1);
Tobi v2(2,2);
switch (z)
{
case 'a':
v1.add(x,y);
cout << x << " + " << y << "i" << endl;
break;
case 's':
v1.sub(x,y);
cout << x << " + " << y << "i" << endl;
break;
case 'm':
v1.mul(x,y);
cout << x << " + " << y << "i" << endl;
break;
case 'd':
v1.mul(x,y);
cout << x << " + " << y << "i" << endl;
break;
}
return 0;
}
|