这个程序怎么编写啊???

来源:百度知道 编辑:UC知道 时间:2024/05/16 12:38:57
“利用结构体变量求两个复数的和、差、积。要求设计一个菜单分

别调用函数。”这个程序怎么编写啊?!要求用C语言!谢啦!!!如果回答的好另外奖励50分!!!

#include<iostream>
#include<cmath>
#include <cstring>
#define EPS 1e-6

using namespace std;

class CComplex
{
private:
double real,image;
public:
CComplex(double r=0,double i=0){ real=r; image=i; }

friend istream & operator>>(istream &is,CComplex &com);
friend ostream & operator<<(ostream &os,CComplex &com);
CComplex operator+(CComplex &com);
CComplex operator-(CComplex &com);
CComplex operator*(CComplex &com);

double module(void);
};

/***********************************************************/
istream & operator>>(istream &is,CComplex &com)
{
char str[20];
is>>str;
int len=strlen(str);
int n=0,i,sign=1;
com.image=com.real=0;
for(i=0;i<len;i++)
{
if((str[i]<'0