源代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x, y, w, z;
Console.WriteLine("请输入第一个复数实部的值:");
x = Convert.ToInt32(Console .ReadLine ());
Console.WriteLine("请输入第一个复数虚部的值:");
y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第二个复数实部的值:");
w = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第二个复数虚部的值:");
z = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("两个复数相加的和为:{0}+{1}i", Complex.j(x, w), Complex.i(y, z));
Console.WriteLine("两个复数相减的和为:{0}+{1}i", Complex.a(x, w), Complex.b(y, z));
Console.ReadKey();
}
}
class Complex
{
static public double j(double x, double w)
{
return x + w;
}
static public double i(double y, double z)
{
return y + z;
}
static public double b(double y, double z)
{
return y - z;
}
static public double a(double x, double w)
{
return x - w;
}
}
}
运行结果:
总结:
让我知道了什么是复数,加深我对它的认识