Skip to content
Snippets Groups Projects
Forked from Nicolas Thiery / wims-info
99 commits behind, 1 commit ahead of the upstream repository.
struct_procedure_1.cpp 489 B
#include <iostream>

using namespace std;

struct cpx{
	double real;
	double img;
};

void sum(cpx x, cpx y, cpx &z)
{
	z.real = x.real + y.real + z.real;
	z.img = x.img + y.img + z.img;
}

void multiply(cpx x, cpx y, cpx &z)
{
	z.real = x.real * y.real - (x.img * y.img); 
	z.img = x.real * y.img + x.img * y.real;
}

int main()
{
	cpx x = { 0, 4 };
	cpx y = { 2, 3 };
	cpx z = { 1, -2 };

	sum(x, y, z);
	
	multiply(z, y, x);

	cout << "x = (" << x.real << "," << x.img << ")" << endl;
}