static void Main(string[] args) { TComplex sp = new TComplex(); sp.input(); Console.Write("sp = "); sp.output(); TComplex sp1, sp2, sp3, sp4, sp5; sp1 = new TComplex(); Console.Write("sp1 = "); sp1.output(); sp2 = new TComplex(2, 3); Console.Write("sp2 = "); sp2.output(); sp3 = sp1 - sp2; Console.Write("sp3 = sp1 - sp2 = "); sp3.output(); sp4 = sp1 + sp2; Console.Write("sp4 = sp1 + sp2 = "); sp4.output(); sp5 = sp4 * sp3; Console.Write("sp5 = sp4 * sp3 = "); sp5.output(); }
public static TComplex operator *(TComplex a, TComplex b) { TComplex c = new TComplex(); c.thuc = a.thuc * b.thuc - a.ao * b.ao; c.ao = a.ao * b.thuc + a.thuc * b.ao; return(c); }
public static TComplex operator -(TComplex a, TComplex b) { TComplex c = new TComplex(); c.thuc = a.thuc - b.thuc; c.ao = a.ao - b.ao; return(c); }