tst_power.cc

来自「Financial Recipes」· CC 代码 · 共 16 行

CC
16
字号
#include <iostream>  // input output operations#include <cmath>      // mathematics libraryusing namespace std;   // the above is part of the standard namespacedouble power(double x, double n){    // define a simple power function     double p = exp(n*log(x));    return p;};int main(){    for (int n=1;n<6;n++){	cout << " 2^" << n << " = " << power(2,n) << endl;    };};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?