电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

20142015c考试题库VIP免费

20142015c考试题库_第1页
1/38
20142015c考试题库_第2页
2/38
20142015c考试题库_第3页
3/38
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 方法中调用时,会根据...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

20142015c考试题库

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部