C++ 中複數的 exp() 函式
在本文中,我們將討論 C++ STL 中複數的 std::exp() 函式的工作原理、語法和示例。
什麼是 std::exp()?
C++ STL 中有 std::exp() 複數函式,其定義在 <complex> 標頭檔案中。複數的 exp() 函式與普通的 exp() 相同,後者也是一個內建函式,定義在 <cmath> 標頭檔案中,用於查詢輸入的指數值。此函式是複數的指數,並返回複數的指數。
語法
exp(complex <T> num);
引數
該函式接受以下引數:
- num - 這是一個複數,我們希望找到它的指數。
返回值
此函式返回 num 的指數值。
示例
輸入
exp(complex<double> complexnumber(-1.0, 0.0));
輸出
The result is : (-1, 0) is (0.367879, 0)
示例
#include <bits/stdc++.h>
using namespace std;
int main(){
complex<double> complexnumber(-1.0, 0.0);
cout<<"The result is : " << complexnumber<< " is "<< exp(complexnumber)<< endl;
return 0;
}輸出
The result is : (-1, 0) is (0.367879, 0)
示例
#include <bits/stdc++.h>
using namespace std;
int main(){
complex<double> complexnumber(0.0, 1.0);
cout<<"The result is : " << complexnumber<< " is "<< exp(complexnumber)<< endl;
return 0;
}輸出
The result is : (0, 1) is (0.540302,0.841471)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP