Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct complex_number {
- double a;
- double b;
- };
- complex_number addition(const complex_number& x, const complex_number& y) {
- return complex_number{ (x.a + y.a), (x.b + y.b) };
- }
- complex_number deduction(const complex_number& x, const complex_number& y) {
- return complex_number{ (x.a - y.a), (x.b - y.b) };
- }
- void show(complex_number cn) {
- cout << cn.a << " " << cn.b << endl;
- }
- int main() {
- setlocale(LC_ALL, "ru");
- complex_number z1{ 5, -6 }, z2{ -3, 2 };
- complex_number z3 = addition(z1, z2);
- show(z3);
- z3 = deduction(z1, z2);
- show(z3);
- }
Advertisement
Add Comment
Please, Sign In to add comment