?? 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 + -