| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1489 人关注过本帖
标题:[求助]关于复数加减乘除,共轭的程序...急用
只看楼主 加入收藏
VanGogh
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-5-27
收藏
 问题点数:0 回复次数:2 
[求助]关于复数加减乘除,共轭的程序...急用
要求实现复数加减乘除,求复数的共轭复数,以及输入复数,提取其实部'虚部并输出,高手帮忙了```
搜索更多相关主题的帖子: 共轭 复数 加减乘除 
2006-11-09 14:02
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 

在输出的时候加i就可以了!


该学习了。。。
2006-11-09 15:58
maoguoqing
Rank: 6Rank: 6
来 自:重庆
等 级:贵宾
威 望:28
帖 子:2980
专家分:19
注 册:2005-12-5
收藏
得分:0 

实现了加减乘除,输出,其余功能自己加
class Complex
{
private:
double real; //实部
double imag; //虚部
public:
Complex(){real=0;imag=0;}
Complex(double r,double i){real=r;imag=i;}
Complex operator +(const Complex &c2 );
Complex operator -(const Complex &c2 );
Complex operator *(const Complex &c2 );
Complex operator /(const Complex &c2 );
void display();
};

Complex Complex::operator+(const Complex &c2)
{
Complex c;
c.real=real+c2.real;
c.imag=imag+c2.imag;
return c;
}

Complex Complex::operator-(const Complex &c2)
{
Complex c;
c.real=real-c2.real;
c.imag=imag-c2.imag;
return c;
}

Complex Complex::operator*(const Complex &c2)
{
Complex c;
c.real=real*c2.real;
c.imag=imag*c2.imag;
return c;
}

Complex Complex::operator/(const Complex &c2)
{
Complex c;
c.real=real/c2.real;
c.imag=imag/c2.imag;
return c;
}

void Complex::display()
{
cout<<"("<<real<<","<<imag<<"i)"<<endl;
}

[此贴子已经被作者于2006-11-9 18:27:39编辑过]


天行健,君子以自强不息!!QQ:68660681
2006-11-09 18:27
快速回复:[求助]关于复数加减乘除,共轭的程序...急用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017239 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved