ImageVerifierCode 换一换
格式:DOCX , 页数:19 ,大小:18.04KB ,
资源ID:5479306      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-5479306.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java 编写的复数加减乘除.docx)为本站会员(b****3)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

java 编写的复数加减乘除.docx

1、java 编写的复数加减乘除secondComplex.javapackage secondComplex;public class secondComplex private double real; private double vir; public secondComplex() this(0.0,0.0); public secondComplex(double real, double vir) this.real = real; this.vir = vir; public secondComplex(secondComplex c) this.real = c.real; th

2、is.vir = c.vir; /求共轭复数 public static secondComplex Conjugate(secondComplex a) return new secondComplex(a.real, -a.vir); /求复数的相反数 public secondComplex oppositeComplex(secondComplex a) return new secondComplex(-a.real, -a.vir); /求复数的倒数 public static secondComplex Reciprocal(secondComplex a) secondComp

3、lex b = secondComplex.Conjugate(a); b.Multiplication(a); b.real = b.real +b.vir; a = secondComplex.Conjugate(a); if(Math.abs(b.real) 1e-6) b.real = 0; return null; return new secondComplex(a.real/b.real, a.vir/b.real); /* * this+=a * return * */ public void Add(secondComplex a) this.real += a.real;

4、this.vir += a.vir; /* * this-=a; */ public void Sub(secondComplex a) a = a.oppositeComplex(a); this.Add(a); /* * this*=a; */ public void Multiplication(secondComplex a) double tmp; tmp = this.real; this.real = this.real * a.real - this.vir * a.vir; this.vir = tmp * a.vir + this.vir * a.real; /* *thi

5、s /= b * return */ public void Division(secondComplex a) secondComplex b = Multiplication(this, secondComplex.Reciprocal(a); if(b = null) return; this.real = b.real; this.vir = b.vir; /* * * c = this + a * return */ public secondComplex Add(secondComplex a, int type) return Add(this, a); /* * c = th

6、is - a */ public secondComplex Sub(secondComplex a, int type) a = a.oppositeComplex(a); return Add(this, a); /* * c = this * a */ public secondComplex Multiplication(secondComplex a, int type) return Multiplication(this, a); /* *c = this / b * return */ public secondComplex Division(secondComplex a,

7、int type) return Division(this,a); /* * c = a + b * param a * param b * return */ public static secondComplex Add(secondComplex a, secondComplex b) return new secondComplex(a.real + b.real, a.vir + b.vir); /* * c = a - b * return */ public secondComplex Sub(secondComplex a, secondComplex b) b = b.op

8、positeComplex(b); return Add(a, b); /* * c = a * b * return */ public static secondComplex Multiplication(secondComplex a, secondComplex b) if(b = null) return null; return new secondComplex(a.real * b.real - a.vir * b.vir , a.real * b.vir + a.vir * b.real); /* *c = a / b * return */ public secondCo

9、mplex Division(secondComplex a, secondComplex b) if(secondComplex.Reciprocal(b) = null) return null; return Multiplication(a, secondComplex.Reciprocal(b); public double getReal() if(Math.abs(real) 1e-6) real = 0; return real; public void setReal(double real) this.real = real; public double getVir()

10、if(Math.abs(vir) 1e-6) vir = 0; return vir; public void setVir(double vir) this.vir = vir; public String toString() if(Math.abs(this.getReal() 1e-6 & Math.abs(this.getVir() 1e-6) System.out.println(0); else if(Math.abs(this.getReal() 1e-6) if(Math.abs(this.getVir() 0) System.out.println(i); else Sys

11、tem.out.println(-i); else System.out.println(this.getVir()+i); else if(Math.abs(this.getVir() 0) System.out.println(+ i); else System.out.println(- i); else if(Math.abs(this.getVir() 1e-6) System.out.println( + this.getVir()+i); else if(this.getVir() 0) System.out.println(this.getReal() + + + this.g

12、etVir() + i); else System.out.println(this.getReal() + - + Math.abs(this.getVir() + i); return ; Complex.javapackage secondComplex;public class Complex extends secondComplex private double mo; private double jiao; public Complex() this(1.0,Math.PI/4); public Complex(double mo, double jiao) super(Com

13、plex.returnX(mo, jiao), Complex.returnY(mo, jiao); public static double returnX(double mo, double jiao) return mo * Math.cos(jiao); public static double returnY(double mo, double jiao) return mo * Math.sin(jiao); public static double returnMo(double x, double y) x = Math.abs(x); y = Math.abs(y); if(

14、x 1e-6) x = 0; if(y 1e-6) y = 0; return Math.sqrt(x*x + y*y); public static double returnJiao(double x, double y) double tmp1; int st1; int st2; double tmp2; /横轴正向:1;反向:-1;原点:0 /纵轴正向:1;反向:-1;原点:0 if(Math.abs(x) 0) tmp1 = x; st1 = 1; else tmp1 = x; st1 = -1; if(Math.abs(y) 0) tmp2 = y; st2 = 1; else

15、tmp2 = y; st2 = -1; if(0 = st1 & 0 = st2) System.out.println(复数无辐角); return -1000; else if(0 = st1 & 0 != st2) if(st2 0) return Math.PI/2; else return -Math.PI/2; else if(st1 0 & tmp2 != 0.0) return Math.atan(tmp2/tmp1); else if(st1 0 & tmp2 != 0.0) return Math.atan(tmp2/tmp1)-Math.PI; return -1000;

16、 public String toString() if(Complex.returnJiao(this.getReal(), this.getVir() = -900) return ; return 计算结果模值为: + (double)(int)(Complex.returnMo(this.getReal(), this.getVir()*1000)/1000 + 角度为: + (double)(int)(Complex.returnJiao(this.getReal(), this.getVir()*1000)/1000; public double getMo() return mo

17、; public void setMo(double mo) this.mo = mo; public double getJiao() return jiao; public void setJiao(double jiao) this.jiao = jiao; /* * this+=a */ public void Add(Complex a) this.setReal(this.getReal() + a.getReal(); this.setVir(this.getVir() + a.getVir(); public void Sub(Complex a) secondComplex

18、tmp = a.oppositeComplex(new secondComplex(a.getReal(), a.getVir(); Complex d = new Complex(); d.setReal(tmp.getReal(); d.setVir(tmp.getVir(); this.Add(d); public void Multiplication(Complex a) this.setReal(this.getReal() * a.getReal() - this.getVir() * a.getVir(); this.setVir( this.getReal() * a.get

19、Vir() + this.getVir() * a.getReal(); public void Division(Complex a) secondComplex tmp = new secondComplex(a.getReal(), a.getVir(); /Complex b = Multiplication(this, secondComplex.Reciprocal(tmp); secondComplex b = secondComplex.Reciprocal(tmp); if(b = null) return; Complex c = new Complex(Complex.r

20、eturnMo(b.getReal(), b.getVir(), Complex.returnJiao(b.getReal(), b.getVir(); Complex d = Multiplication(this, c); this.setReal(d.getReal(); this.setVir(d.getVir(); /* * c = this + a * return */ public Complex Add(Complex a, int type) return Add(this, a); public Complex Sub(Complex c, int type) secon

21、dComplex a = new secondComplex(c.getReal(),c.getVir(); a = a.oppositeComplex(a); Complex d = new Complex(Complex.returnMo(a.getReal(), a.getVir(), Complex.returnJiao(a.getReal(), a.getVir(); return Add(this, d); public Complex Multiplication(Complex a, int type) return Multiplication(this, a); publi

22、c Complex Division(Complex a,int type) return Division(this,a); /* * c = a + b * return */ public static Complex Add(Complex a, Complex b) secondComplex c = new secondComplex(a.getReal() + b.getReal(), a.getVir() + b.getVir(); Complex d = new Complex(Complex.returnMo(c.getReal(), c.getVir(), Complex

23、.returnJiao(c.getReal(), c.getVir(); return d; public Complex Sub(Complex a, Complex d) secondComplex b = new secondComplex(d.getReal(),d.getVir(); b = b.oppositeComplex(b); Complex c = new Complex(Complex.returnMo(b.getReal(), b.getVir(), Complex.returnJiao(b.getReal(), b.getVir(); return Add(a, c)

24、; public static Complex Multiplication(Complex a, Complex b) if(b = null) return null; secondComplex bb = new secondComplex(a.getReal() * b.getReal() - a.getVir() * b.getVir() , a.getReal() * b.getVir() + a.getVir() * b.getReal(); Complex c = new Complex(Complex.returnMo(bb.getReal(), bb.getVir(), C

25、omplex.returnJiao(bb.getReal(), bb.getVir(); return c; public Complex Division(Complex a, Complex c) secondComplex b = new secondComplex(c.getReal(), c.getVir(); secondComplex f = secondComplex.Reciprocal(b); if(f = null) return null; Complex d = new Complex(Complex.returnMo(f.getReal(), f.getVir(),

26、 Complex.returnJiao(f.getReal(), f.getVir(); return Multiplication(a, d); demoSecondComplex.javapackage secondComplex;public class demoSecondComplex public static void main(String args) System.out.println(-mo jiao-); Complex a = new Complex(1.0, 0.5*Math.PI); Complex b = new Complex(2.0, 0.5*Math.PI); a.Add(b); System.out.println(a); a = b.Add(a, 0); System.out.println(a); Complex d = a.Add(b, a); System.out.println(d); a.Sub(b); System.out.print

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2