Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <typeinfo>
- #include <sstream>
- using namespace std;
- class L_zesp{
- private:
- int re, im;
- public:
- L_zesp(double a=0, double b=0){
- re=a;
- im=b;
- }
- L_zesp operator +(L_zesp &B){
- L_zesp w;
- w.re = re + B.re;
- w.im = im + B.im;
- return w;
- }
- L_zesp operator -(L_zesp &B){
- L_zesp w;
- w.re = re - B.re;
- w.im = im - B.im;
- return w;
- }
- L_zesp operator *(L_zesp &B){
- L_zesp w;
- w.re = (re*B.re-(im*B.im));
- w.im = (re*B.im+(im*B.re));
- return w;
- }
- L_zesp operator /(L_zesp &B){
- L_zesp w;
- if((B.im*B.im+(B.re*B.re))<=0){
- w.re=0;
- w.im=0;
- return w;
- }
- w.re = (re*B.re+(im*B.im))/(B.im*B.im+(B.re*B.re));
- w.im = (im*B.re-(re*B.im))/(B.im*B.im+(B.re*B.re));
- return w;
- }
- void druk(){
- cout<<"z=["<<re<<"+i*"<<im<<"]"<<endl;
- }
- };
- int main(){
- L_zesp A1(2,6),A2(7,-3),A3;
- A3=A1+A2;
- A3.druk();
- A3=A1-A2;
- A3.druk();
- A3=A1*A2;
- A3.druk();
- A3=A1/A2;
- A3.druk();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement