C++ 中複數的 arg() 函式
複數是表示為 a + bi 的數字,其中 a 和 b 是實數。i是該數的虛部。
幅角是正軸與複數向量的夾角。對於複數
z = x + iy 用arg(z) 表示,
若要找到複數的幅角,則該複數頭的 complex 標標頭檔案中將具有一個名為arg() 的函式。
語法
arg(complex_number);
引數
該函式將一個複數作為輸入,以計算該複數的幅角。
返回值
該函式返回複數的幅角。
例項
#include<iostream> #include<complex.h> using namespace std; int main (){ double a = 12.0, b = 56.0; complex<double> complexnumber (a, b); cout<<"The argument of complex number "<<a<<" + i"<<b<< " is: "; cout<<arg(complexnumber)<<endl; return 0; }
輸出
複數 12 + i56 的幅角是:1.3597
廣告