c real c 入门


c real c 入门

文章插图
大家好,小豆豆来为大家解答以上的问题 。c 入门,c real这个很多人还不知道,现在让我们一起来看看吧!
【c real c 入门】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 ) =imaginary part of c1 is imag ( c1 ) = 3. 。
本文到此分享完毕,希望对大家有所帮助 。