Advertisement
Alex_Fuleki21

a,b

Mar 14th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. struct complex
  4. {
  5. double re;
  6. double im;
  7. }z,x;
  8. void citire(struct complex&z)
  9. {
  10. cin>>z.re>>z.im;
  11. }
  12. void scriere (struct complex&z)
  13. {
  14. if(z.im>0)
  15. {
  16. cout<<z.re<<"+"<<z.im<<"*i";
  17. }
  18. if(z.im<0)
  19. {
  20. cout<<z.re<<z.im<<"*i";
  21. }
  22. if(z.im==0)
  23. {
  24. cout<<z.re;
  25. }
  26. }
  27. int main ()
  28. {
  29. citire(z);
  30. scriere(z);
  31. citire(x);
  32. scriere(x);
  33. int s=0,s1=0;
  34. if(x.re>=0&&x.im>=0&&z.re>=0&&z.im>=0)
  35. {
  36. s=x.re+z.re;
  37. s1=x.im+z.im;
  38. }
  39. cout<<s<<"+"<<s1<<"*i";
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement