TYPE complex real AS DOUBLE imag AS DOUBLE END TYPE DECLARE SUB suma (a AS complex, b AS complex, c AS complex) DECLARE SUB rest (a AS complex, b AS complex, c AS complex) DECLARE SUB mult (a AS complex, b AS complex, c AS complex) DECLARE SUB divi (a AS complex, b AS complex, c AS complex) DECLARE SUB neg (a AS complex, b AS complex) DECLARE SUB inv (a AS complex, b AS complex) DECLARE SUB conj (a AS complex, b AS complex) CLS DIM x AS complex DIM y AS complex DIM z AS complex x.real = 1 x.imag = 1 y.real = 2 y.imag = 2 PRINT "Siendo x = "; x.real; "+"; x.imag; "i" PRINT " e y = "; y.real; "+"; y.imag; "i" PRINT CALL suma(x, y, z) PRINT "x + y = "; z.real; "+"; z.imag; "i" CALL rest(x, y, z) PRINT "x - y = "; z.real; "+"; z.imag; "i" CALL mult(x, y, z) PRINT "x * y = "; z.real; "+"; z.imag; "i" CALL divi(x, y, z) PRINT "x / y = "; z.real; "+"; z.imag; "i" CALL neg(x, z) PRINT " -x = "; z.real; "+"; z.imag; "i" CALL inv(x, z) PRINT "1 / x = "; z.real; "+"; z.imag; "i" CALL conj(x, z) PRINT " x* = "; z.real; "+"; z.imag; "i" END SUB suma (a AS complex, b AS complex, c AS complex) c.real = a.real + b.real c.imag = a.imag + b.imag END SUB SUB inv (a AS complex, b AS complex) denom = a.real ^ 2 + a.imag ^ 2 b.real = a.real / denom b.imag = -a.imag / denom END SUB SUB mult (a AS complex, b AS complex, c AS complex) c.real = a.real * b.real - a.imag * b.imag c.imag = a.real * b.imag + a.imag * b.real END SUB SUB neg (a AS complex, b AS complex) b.real = -a.real b.imag = -a.imag END SUB SUB conj (a AS complex, b AS complex) b.real = a.real b.imag = -a.imag END SUB SUB divi (a AS complex, b AS complex, c AS complex) c.real = ((a.real * b.real + b.imag * a.imag) / (b.real ^ 2 + b.imag ^ 2)) c.imag = ((a.imag * b.real - a.real * b.imag) / (b.real ^ 2 + b.imag ^ 2)) END SUB SUB rest (a AS complex, b AS complex, c AS complex) c.real = a.real - b.real c.imag = a.imag - b.imag END SUB