当前位置: 代码迷 >> 综合 >> c++:sqrt
  详细解决方案

c++:sqrt

热度:39   发布时间:2024-02-24 05:14:48.0

功能:开平方根

头文件:

#include<cmath>

函数声明:

double sqrt (double x);
float sqrt (float x);
long double sqrt (long double x);
double sqrt (T x);           // additional overloads for integral types

例子:

/* sqrt example */
#include <stdio.h>      /* printf */
#include <math.h>       /* sqrt */int main ()
{double param, result;param = 1024.0;result = sqrt (param);printf ("sqrt(%f) = %f\n", param, result );return 0;
}

运行结果: