Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- struct complex
- {
- double re,im;
- };
- complex add(complex z, complex w)
- {
- complex t;
- t.re = z.re+w.re;
- t.im=z.im+w.im;
- return t;
- }
- //makrodefinicja
- #define sqr(x) ((x)*(x))
- double module (complex z)
- {
- return sqrt(sqr(z.re)+sqr(z.im));
- }
- void print (complex z)
- {
- cout<<"("<<z.re<<","<<z.im<<")"<<endl;
- }
- main()
- {
- complex z, w, t;
- z.re=1; z.im=-3;
- w.re=-2; w.im=2.5;
- t=add(z,w);
- print(t);
- cout<<module(t)<<endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement