博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
九周 项目 1
阅读量:7237 次
发布时间:2019-06-29

本文共 1439 字,大约阅读时间需要 4 分钟。

/** 程序的版权和版本号声明部分:* Copyright (c) 2013, 烟台大学计算机学院* All rights reserved.* 文件名:test.cpp* 作    者:赵加响* 完毕日期:2014年 4月 22日* 输入描写叙述:* 程序输出:* 问题分析:略* 算法设计:略*/#include 
using namespace std;class Complex{public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r; imag=i;} Complex operator+(Complex &c2); Complex operator-(Complex &c2); Complex operator*(Complex &c2); Complex operator/(Complex &c2); friend ostream&operator<<(ostream&,Complex&); friend Complex operator-(Complex &c);//取负private: double real; double imag;};//以下定义成员函数Complex operator-(Complex &c){ Complex c1; c1.imag=0-c.imag; c1.real=0-c.real; return c1;}Complex Complex::operator+(Complex &c2){ Complex c; c.real=real+c2.real; c.imag=imag+c2.imag; return c;}Complex Complex::operator-(Complex &c2){ Complex c; c.real=real-c2.real; c.imag=imag-c2.imag; return c;}Complex Complex::operator*(Complex &c2){ Complex c; c.real=(real*c2.real-imag*c2.imag); c.imag=imag*c2.real+real*c2.imag; return c;}Complex Complex::operator/(Complex &c2){ Complex c; c.real=(real*c2.real+imag*c2.imag)/(c2.real*c2.real+c2.imag*c2.imag); c.imag=(imag*c2.real-real*c2.imag)/(c2.real*c2.real+c2.imag*c2.imag); return c;}ostream&operator<<(ostream&output,Complex&c){ if(c.imag>0) { output<<"("<
<<"+"<
<<"i)"<

感悟:还行吧!!

!。!

你可能感兴趣的文章
如果不使用 Navigate2 的方法去访问现有页面,如何将JS写到该浏览器中???
查看>>
Form表单中method="post/get'的区别
查看>>
'telnet' is not recognized as an internal or external command
查看>>
什么是 MIME Type?
查看>>
c#设计模式第一天
查看>>
Jquery.Form和jquery.validate 的使用
查看>>
c++ string 和wstring 之间的互相转换函数
查看>>
mathematica练习程序(图像取反)
查看>>
mssql和mysql区别
查看>>
Java安全通信概述
查看>>
C++ vector类型要点总结
查看>>
在global里捕获黄页并写入异常日志库
查看>>
如何使用Transact-SQL进行事务处理[示例]
查看>>
cxgrid在内置右键菜单的后面增加菜单项
查看>>
第三届云计算大会 - RackSpace CTO John Engates:开放云的必要性(转载)
查看>>
步步为营 C# 技术漫谈 三、公共语言运行库(CLR)
查看>>
FIREDAC的TFDJSONDataSets和TFDJSONDeltas查询和提交数据
查看>>
分类问题中的数据不平衡问题
查看>>
花间美人:古风 CG插画技法
查看>>
xBIM 基本的模型操作
查看>>