📜  polar()函数,用于C++中的复数

📅  最后修改于: 2021-05-30 20:17:58             🧑  作者: Mango

复数头文件中定义了复数polar()函数.polar函数用于从相角和幅值中查找复数。

句法:

polar(mag, angle)

范围:

  • mag:表示复数的大小。
  • angle:代表相位角。

返回值:该函数返回一个复数,该复数由相角和幅值获得。

下面的程序说明了上述函数:

程序1:

// C++ program to demonstrate
// example of polar() function.
#include 
using namespace std;
   
// driver function
int main ()
{
  cout << "The complex number whose magnitude is 4.0";
  cout << " and phase angle 1.5";
   
  // use of polar() function
  cout << " is " << polar (4.0, 1.5) << endl;
   
  return 0;
}
输出:
The complex number whose magnitude is 4.0 and phase angle 1.5 is (0.282949,3.98998)

程式2:

// C++ program to demonstrate
// example of polar() function.
#include 
using namespace std;
   
// driver function
int main ()
{
  cout << "The complex number whose magnitude is 2.0";
  cout << " and phase angle 0.5";
   
  // use of polar() function
  cout << " is " << polar (2.0, 0.5) << endl;
   
  return 0;
}
输出:
The complex number whose magnitude is 2.0 and phase angle 0.5 is (1.75517,0.958851)
想要从精选的最佳视频中学习和练习问题,请查看有关从基础到高级C++的C++基础课程以及有关语言和STL的C++ STL课程。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”