📄 ccomplex.h
字号:
//#include "stdafx.h"
#include <iostream>
class comp
{
float a;
float b;
public:
comp(float x=0,float y=0):a(x),b(y){}
comp operator+(comp &x)
{
comp c;
c.a=a+x.a;
c.b=b+x.b;
return c;
}
comp operator-(comp &x)
{
comp c;
c.a=a-x.a;
c.b=b-x.b;
return c;
}
comp operator*(comp &x)
{
comp c;
c.a=a*x.a-b*x.b;
c.b=a*x.b+b*x.a;
return c;
}
comp operator/(comp &x)
{
comp c;
float temp;
temp=x.a*x.a+x.b*x.b;
if (temp==0)
printf("can't div zero!");
c.a=(a*x.a+b*x.b)/temp;
c.b=(b*x.a-a*x.b)/temp;
return c;
}
void input(float x,float y)
{a=x;
b=y;
}
void output()
{printf("%f+%fi\n",a,b);
}
float getreal()
{
return a;
}
float getimag()
{
return b;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -