实例 C++ 将 cmath 头文件用于其他数学函数

x
 
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  cout << sqrt(64) << "\n";
  cout << round(2.6) << "\n";
  cout << log(2) << "\n";
  return 0;
}
                    

输出结果

8
3
0.693147