2014-2015-1C#考试题库 一:控制台应用程序 1.定义描述复数的类Complex,具体要求如下: (1) 通过重载运算符:+、-、*、/,直接实现两个复数之间的各种运算。 (2) 其中,两个复数相乘的计算公式为(a+bi)*(c+di)=(ac-bd)+(ad+bc)i; (3) 两个复数相除的计算公式为(a+bi)/(c+di)=(ac+bd)/(c*c+d*d)+(bc-ad)/(c*c+d*d) (4) 定义主函数测试类,在主函数中定义两个复数2+3i 和 1+2i,实现两个复数的加减,并将结果输出。 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace L1 { class Complex { double real, image; public Complex(double a, double b) { this.real = a; this.image = b; } public static Complex operator +(Complex a, Complex b) { return new Complex(a.real + b.real, a.image + b.image); } public static Complex operator -(Complex a, Complex b) { return new Complex(a.real - b.real, a.image - b.image); } public static Complex operator *(Complex a, Complex b) { return new Complex(a.real * b.real - a.image * b.image, a.real * b.image + a.image * b.real); } public static Complex operator /(Complex a, Complex b) { return new Complex((a.real * b.real + a.image * b.image) / (b.real * b.real + b.image * b.image), (a.image * b.real - a.real * b.image) / (b.real * b.real + b.image * b.image)); } public void print() { Console.Write(real + "+(" + image + ")i\n"); } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace L1 { class Program { static void Main(string[] args) { Complex a1 = new Complex(2, 3); Complex a2 = new Complex(1, 2); Complex c = a1 + a2; c.print(); Complex d = a1 - a2; d.print(); Complex e = a1 * a2; e.print(); Complex f = a1 / a2; f.print(); Console.Read(); } } } 2. 定义Maxer 类,具体要求如下: (1) 类中声明的方法Max()要有三种重载形式 (2) 在Main 方法中调用时,会根据...