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