(资料图片仅供参考)
1、Real 是实数的意思。
2、在复数里,real 表示取实部函数。
3、应当用小写#include #include int main( ){using namespace std;complex c1 ( 4.0 , 3.0 ); // c1 是复数 cout << "The complex number c1 = " << c1 << endl;double dr1 = real ( c1 ); // 取c1的实部cout << "The real part of c1 is real ( c1 ) = " << dr1 << "." << endl;double di1 = imag ( c1 ); // 取c1的虚部cout << "The imaginary part of c1 is imag ( c1 ) = " << di1 << "." << endl;}上面程序 输出The complex number c1 = (4,3)The real part of c1 is real ( c1 ) = 4.The imaginary part of c1 is imag ( c1 ) = 3.。
本文到此分享完毕,希望对大家有所帮助。
关键词:
对大家有