在複數頭文件中定義了用於複數的arg()函數。此函數用於返回複數z的參數。
用法:
template<class T> T arg (const complex<T>& z);
參數:
- z:它代表給定的複數。
返回:它返回複數的參數。
以下示例程序旨在說明上述函數:-
範例1:
// C++ program to demonstrate
// example of arg() function.
#include <bits/stdc++.h>
using namespace std;
int main ()
{
// defines the complex number:(5.0 + 12.0i)
complex<double> complexnumber (5.0, 12.0);
// prints the argument of the complex number
cout << "The argument of " << complexnumber << " is:";
cout << arg(complexnumber) << endl;
return 0;
}
輸出:
The argument of (5,12) is:1.17601
範例2:
// C++ program to demonstrate
// example of arg() function
#include <bits/stdc++.h>
using namespace std;
int main ()
{
// defines the complex number:(4.0+3.0i)
complex<double> complexnumber (4.0, 3.0);
// prints the argument of the complex number
cout << "The argument of " << complexnumber << " is:";
cout << arg(complexnumber) << endl;
return 0;
}
輸出:
The argument of (4,3) is:0.643501
相關用法
- C++ complex exp()用法及代碼示例
- C++ complex cos()用法及代碼示例
- C++ complex pow()用法及代碼示例
- C++ complex log()用法及代碼示例
- C++ complex tan()用法及代碼示例
- C++ complex acosh()用法及代碼示例
- C++ complex cosh()用法及代碼示例
- C++ complex acos()用法及代碼示例
- C++ complex sqrt()用法及代碼示例
- C++ complex tanh()用法及代碼示例
- C++ complex atanh()用法及代碼示例
- C++ complex asin()用法及代碼示例
- C++ complex sinh()用法及代碼示例
- C++ complex atan()用法及代碼示例
- C++ complex polar()用法及代碼示例
注:本文由純淨天空篩選整理自bansal_rtk_大神的英文原創作品 arg() function for Complex Number in C++。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。