文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > C++复数计算器
侵权投诉

C++复数计算器

所涉及的复数计算器可以进行+ -乘运算2.设计重载函数,要求能接收从键盘输入a+bi形式的复数,在程序中可以识别出实部、虚部并进行赋值3.设计计算器测试程序,对加减法进行测试,要求在两位数以内,对乘法进行测试,乘法要求为一位数的运算。

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<<"("<<c.real<<"+"<<c.imag<<"i)";

else

output<<"("<<c.real<<" "<<c.imag<<"i)";

return output;

}

//--------------------------------------------------

istream & operator>>(istream &input,Complex &c)

{

cout<<"请输入一个复数,实部和虚部,中间用空格隔开:";

input>>c.real>>c.imag;

return input;

}

//======================================================================= //=================功能函数(普通函数)的定义============================ //复数加法

void complexAdd()

{

上一页第2页

你可能喜欢

热门文档

相关文档

  • C++复数计算器

    #include<iostream> #include<cmath> #include<cstdlib> #include<cstring> #...{ user=user1; user.nTime++; cout<<"欢迎您再次使用复数计算器!"; ...

  • 复数计算器C++

    复数计算器C++_IT/计算机_专业资料。课程设计报告课程设计题目: 课程设计题目:...c:Crational&):ostream& <<friend>>+operator>>(in:istream&,c:Crational&...

  • C++课程设计复数计算器

    C++课程设计复数计算器_工学_高等教育_教育专区。C++课程设计C++课程设计实验...=(CComplex&com); int operator>(CComplex&com); int operator<(CComplex&...

  • C++实现的复数计算器(完整版源代码)

    《C++程序设计实践指导》 * * 第 2 章 2.1 一个复数计算器程序 * * (c) yrmuhon, 2009 2.9 ***/ #include <iostream> #include <cmath> #include ...

  • C++课程设计(复数计算器实验报告)

    C++课程设计一份……... 计算机科学与技术专业 复数计算器 A级 njust_smalllion *** *** 2010 年八月底...

  • C++程序设计-复数计算器

    二、课程设计任务及要求 1、 任务: 课程设计选题是 “小型复数计算器” 其...[0]=='c'

  • C++课程设计报告——复数计算器

    C++课程设计报告——复数计算器_工学_高等教育_教育专区。用C++编写简单的复数...=(Complex &c) { if(real==c.real&&imag==c.imag) return 0; else ...

  • C++程序课程设计_复数计算器

    { Complex a,b,c; //cin>>a; //cout<<a; for(int i=0;;) { cout<<"………欢迎使用复数计算器………"<<endl; cout<<"………"<<endl; cout<...

  • C++程序设计-小型复数计算器

    复数计算器!"<<endl; complex c1,c2,c3; c1.input(); cout<<"c1="; print(c1); c2.input(); cout<<"c2="; print(c2);4; Com[0]=c1;...

  • c++课程设计 复数计算器 源代码

    c++课程设计 复数计算器 源代码_工学_高等教育_教育专区。亲,自己做的课程...()%20-10; CComplex c(real3,image3),d(real4,image4); op=rand()%3...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email