Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class L_zesp
- {
- private:
- int re, im;
- public:
- L_zesp(int a=0, int b=0)
- {
- re=a;
- im=b;
- }
- /*
- void operator +(L_zesp &B)
- {
- re=re+B.re;
- im=im+B.im;
- }
- */
- L_zesp operator +(L_zesp &B)
- {
- L_zesp temp;
- temp.re=re+B.re;
- temp.im=im+B.im;
- return temp;
- }
- L_zesp operator -(L_zesp &B)
- {
- L_zesp temp;
- temp.re=re-B.re;
- temp.im=im-B.im;
- return temp;
- }
- L_zesp operator *(L_zesp &B)
- {
- L_zesp temp;
- temp.re=(re*B.re) - (im*B.im);
- temp.im=(re*B.im) + (im*B.re);
- return temp;
- }
- L_zesp operator /(L_zesp &B)
- {
- L_zesp temp;
- temp.re= ((re*B.re) + (im*B.im))/(pow(2,B.re) + pow(2, B.im));
- temp.im= ((im*B.re) - (re*B.im))/(pow(2,B.re) + pow(2, B.im));
- return temp;
- }
- void drukuj()
- {
- cout << "liczba ma postać re = " << re << ", im = i" << im << endl;
- }
- };
- int main()
- {
- L_zesp A(12,8), B(6,2), C;
- // A.drukuj();
- // B.drukuj();
- // C.drukuj();
- C = A + B;
- C.drukuj();
- C = A - B;
- C.drukuj();
- C = A * B;
- C.drukuj();
- C = A / B;
- C.drukuj();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement