要求建立复数类,包括复数的实部虚部,和对复数进行加减乘除运算的函数.使用MFC,编写基于对话框的Windo
来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/05/25 20:11:17
要求建立复数类,包括复数的实部虚部,和对复数进行加减乘除运算的函数.使用MFC,编写基于对话框的Windo
#include "stdafx.h"
#include<iostream>
using namespace std;
class complex
{
protected:
double real;
double image;
public:
complex(double r=0,double i=0);
complex(const complex&other);
void print();
complex operator-(const complex&other);
};
complex::complex(double r,double i)
{
real=r;
image=i;
}
complex::complex(const complex &other)
{
real=other.real;
image=other.image;
}
void complex::print()
{
cout<<real;
if(image>0)
{
cout<<"+"<<image<<"i"<<endl;
}
else
{
cout<<image<<"i"<<endl;
}
cout<<"--------------"<<endl;
}
complex complex::operator-(const complex &other)
{
complex temp;
temp.real=real-other.real;
temp.image=image-other.image;
return temp;
}
void main()
{
complex c1(1.1,2.2);
complex c2(3,-4);
c1.print();
c2.print();
complex c3;
c3=c1-c2;
c3.print();
}
另外,虚机团上产品团购,超级便宜
#include<iostream>
using namespace std;
class complex
{
protected:
double real;
double image;
public:
complex(double r=0,double i=0);
complex(const complex&other);
void print();
complex operator-(const complex&other);
};
complex::complex(double r,double i)
{
real=r;
image=i;
}
complex::complex(const complex &other)
{
real=other.real;
image=other.image;
}
void complex::print()
{
cout<<real;
if(image>0)
{
cout<<"+"<<image<<"i"<<endl;
}
else
{
cout<<image<<"i"<<endl;
}
cout<<"--------------"<<endl;
}
complex complex::operator-(const complex &other)
{
complex temp;
temp.real=real-other.real;
temp.image=image-other.image;
return temp;
}
void main()
{
complex c1(1.1,2.2);
complex c2(3,-4);
c1.print();
c2.print();
complex c3;
c3=c1-c2;
c3.print();
}
另外,虚机团上产品团购,超级便宜
1.定义复数Complex类,使用友元,完成复数的加法、减法、乘法和除法运算,以及对复数的输出.
定义复数类Complex,构造两个对象,并调用成员函数对它们进行加减乘除运算.
复数类的设计和复数的运算.
定义复数类,重载+,*为复数类的成员函数,实现复数类对象的+,*运算.
编写一个名为Complex的类,完成复数的数学运算.同时提供public方法实现复数的加减乘除,并提供打印方法.
定义复述类complex,借助友元函数实现复数之间的加减乘除等算术运算.
编写复数类CComplex,实现整数与实数,复数与复数之间的加.减.乘等各种基本运算
用C++编写程序,定义一个复数类,编写程序重载四则运算符和++、--运算符,实现复数的相关运算;
1、 设计一个复数类Complex,包括实部real和虚部image,设计3个友元函数,实现两个复数的加、减和乘法运算
C++ 一个复数类,运算符重载 + ,实现复数和复数的相加.
matlab 如何进行复数的 fft运算
复数的平方运算,