using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication36
{
class Program
{
static void Main(string[] args)
{
Complex c1 =new Complex();
c1.real=1;
c1.vir = 2;
Complex c2 =new Complex();
c2.real=3;
c2.vir = 4;
Console.WriteLine(c1.CAdd(c2));
Console.WriteLine(c1.CSub(c2));
Console.ReadKey();
}
}
class Complex
{
public double real;
public double vir;
public string CAdd(Complex c)
{
string result = "";
double r;
double v;
r=real+c.real;
if (r > 0) result += "+";
result += r.ToString();
v = vir + c.vir;
if (v > 0) result += "+";
result += v.ToString();
result += "i";
return result;
}
public string CSub(Complex c)
{
string result = "";
double r;
double v;
r=real-c.real;
if (r > 0) result += "+";
result += r.ToString();
v = vir - c.vir;
if (v > 0) result += "-";
result += v.ToString();
result += "i";
return result;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication36
{
class Program
{
static void Main(string[] args)
{
Complex c1 =new Complex();
c1.real=1;
c1.vir = 2;
Complex c2 =new Complex();
c2.real=3;
c2.vir = 4;
Console.WriteLine(c1.CAdd(c2));
Console.WriteLine(c1.CSub(c2));
Console.ReadKey();
}
}
class Complex
{
public double real;
public double vir;
public string CAdd(Complex c)
{
string result = "";
double r;
double v;
r=real+c.real;
if (r > 0) result += "+";
result += r.ToString();
v = vir + c.vir;
if (v > 0) result += "+";
result += v.ToString();
result += "i";
return result;
}
public string CSub(Complex c)
{
string result = "";
double r;
double v;
r=real-c.real;
if (r > 0) result += "+";
result += r.ToString();
v = vir - c.vir;
if (v > 0) result += "-";
result += v.ToString();
result += "i";
return result;
}
}
}