C语言中Real表示什么意思
的有关信息介绍如下:Real 是实数的意思。
在复数里,real 表示取实部函数。
应当用小写
#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.