conj()函数在复杂头文件中定义。此函数用于查找复数z的共轭。如果我们将复数z表示为(real,img),则其共轭为(real,-img)。
句法:
template complex
conj (const complex& Z);
范围:
- z:该方法采用代表复数的mandaory参数z 。
返回值:该函数返回复数z的共轭。
下面的程序说明了C++中用于复数的conj()函数:
范例1:-
// C++ program to demonstrate
// example of conj() function.
#include
using namespace std;
// driver program
int main ()
{
complex complexnumber (3.0, 2.4);
cout << "The conjugate of " << complexnumber << " is: ";
// use of conj() function
cout << conj(complexnumber) << endl;
return 0;
}
输出:
The conjugate of (3,2.4) is: (3,-2.4)
示例2:
// C++ program to demonstrate
// example of conj() function.
#include
using namespace std;
// driver program
int main ()
{
complex complexnumber (2.0, 9.0);
cout << "The conjugate of " << complexnumber << " is: ";
// use of conj() function
cout << conj(complexnumber) << endl;
return 0;
}
输出:
The conjugate of (2,9) is: (2,-9)
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程” 。