arg.cpp

来自「在c环境下的对数据结构进行讲解,包含有例题及答案」· C++ 代码 · 共 25 行

CPP
25
字号
//arg.cpp
// Illustrate the use of each of the complex friend functions.
#include <complex.h>  // This also includes iostream.h.
#include <conio.h>
void main(void)
{
   complex<double> z(3.1, 4.2);
   cout << "z = " << z << "\n";
   cout << "  实数部分 = " << real(z) << "\n";
   cout << "  虚数部分 = " << imag(z) << "\n";
   cout << "z 的共扼复数= " << conj(z) << "\n";

   double mag = sqrt(norm(z));
   double ang = arg(z);

   cout << "z的极坐标:\n";
   cout << "大小 = " << mag << "\n";

   cout << "角弧度 = " << ang << "\n";
   cout << "有极坐标再转换为复数:\n";
   cout << "   z = " << polar(mag,ang) << "\n";
   getch();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?