C++ exp() 函数
C/C++ 库函数 double exp(double x) 返回以 x 为次方的 e 的值。以下是 exp() 函数的声明。
double exp(double x)
参数是浮点值。此函数返回 x 的指数值。
示例
#include <iostream> #include <cmath> using namespace std; int main () { double x = 0; cout << "The exponential value of " << x << " is " << exp(x) << endl; cout << "The exponential value of " << x+1 << " is " << exp(x+1) << endl; cout << "The exponential value of " << x+2 << " is " << exp(x+2) << endl; return(0); }
输出
The exponential value of 0 is 1 The exponential value of 1 is 2.71828 The exponential value of 2 is 7.38906
广告