爱问知识人 爱问教育 医院库

复数四则运算

首页

复数四则运算

请问各位高手,这个程序怎么样改才可以输入一个表达式,然后运行#include<iostream.h>classcomplex{ (){real=imag=0;}complex(doubler,doublei){real=r,imag=i;}complexoperator+(constcomplex&c);complexoperator-(constcomplex&c);complexoperator*(constcomplex&c);complexoperator/(constcomplex&c);friendvoidprint(constcomplex&c); ,imag;};inlinecomplexcomplex::operator+(constcomplex&c){returncomplex(real+c.real,imag+c.imag);}inlinecomplexcomplex::operator-(constcomplex&c){returncomplex(real-c.real,imag-c.imag);}inlinecomplexcomplex::operator*(constcomplex&c){returncomplex(real*c.real-imag*c.imag,real*c.imag+imag*c.real);}inlinecomplexcomplex::operator/(constcomplex&c){returncomplex((real*c.real+imag+c.imag)/(c.real*c.real+c.imag*c.imag),(imag*c.real-real*c.imag)/(c.real*c.real+c.imag*c.imag));}voidprint(constcomplex&c){if(c.imag<0)cout<<c.real<<c.imag<<'i';elsecout<<c.real<<'+'<<c.imag<<'i';}voidmain(){complexcn;constclasscomplex&cn;cout<<"输入表达式"<<endl;cin>>cn;cout<<cn;print(cn);cout<<endl;}

提交回答

全部答案

类似问题

换一换
  • C/C++ 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 174-193
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):