📄 pex6_6.cpp
字号:
#include <iostream.h>
#pragma hdrstop
#include "wex6_9.h"
// evaluate the complex function z**3 -3z*z + 4z - 2
Complex f(Complex z)
{
return z*z*z - Complex(3.0)*z*z + Complex(4.0)*z - 2.0;
}
// note that if the Complex arithmetic operators are implemented
// as friends, the compiler will convert constants such as 3.0
// to Complex automatically. the Complex converters will not
// be necessary
void main(void)
{
// complex number i = 0 +1i
Complex i(0,1), z;
// values for which f is computed
Complex vals[] = { Complex(2,3), Complex(-1,1), Complex(1,1),
Complex(1,-1), Complex(1,0) };
// verify that i*i = -1
cout << "-i*i = " << (-i * i) << endl;
// evaluate f(z), z=2+3i,...,1+0i
for(int k=0;k < 5;k++)
cout << f(vals[k]) << " ";
cout << endl;
}
/*
<Run>
-i*i = (1,0)
(-25,-15) (-4,12) (0,0) (0,0) (0,0)
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -