35657

Untitled

Feb 3rd, 2024
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct complex_number {
  6.     double a;
  7.     double b;
  8. };
  9.  
  10. complex_number addition(const complex_number& x, const complex_number& y) {
  11.     return complex_number{ (x.a + y.a), (x.b + y.b) };
  12. }
  13.  
  14. complex_number deduction(const complex_number& x, const complex_number& y) {
  15.     return complex_number{ (x.a - y.a), (x.b - y.b) };
  16. }
  17.  
  18. void show(complex_number cn) {
  19.     cout << cn.a << " " << cn.b << endl;
  20. }
  21.  
  22. int main() {
  23.  
  24.     setlocale(LC_ALL, "ru");
  25.  
  26.     complex_number z1{ 5, -6 }, z2{ -3, 2 };
  27.  
  28.     complex_number z3 = addition(z1, z2);
  29.  
  30.     show(z3);
  31.  
  32.     z3 = deduction(z1, z2);
  33.  
  34.     show(z3);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment