📄 complex.h
字号:
//------------------------------------
// complex.h
// Complex number
// (c) Reliable Software, 2006
//------------------------------------
#include <iostream.h>
#include <math.h>
class Complex
{
public:
double real;
double imag;
Complex () {real=imag=0;}
Complex (double re)
{
real=re;
imag=0;
}
Complex (double re, double im)
{
real=re;
imag=im;
}
double Re () const { return real; }
double Im () const { return imag; }
inline Complex operator +(const Complex &c)
{
return Complex(real+c.real,imag+c.imag);
}
inline Complex operator -(const Complex &c)
{
return Complex(real-c.real,imag-c.imag);
}
inline Complex operator *(const Complex &c)
{
return Complex(real*c.real-imag*c.imag,real*c.imag+imag*c.real);
}
inline Complex operator /(const Complex &c)
{
return Complex((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));
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -