使用方法:
#include <math.h>
a = sqrt(b);
注意:
1. sqrt()函数是向下取整,即sqrt(10)=3
2. 浮点型使用sqrt()后,输出结果为int整数型
代码实例:
#include <stdio.h>#include <math.h>int main(){int a1,a2,b;double c;b = 10;c = 10.0;//sqrt() 需要添加:#include <math.h>a1 = sqrt(b);//a1=3,向下取整a2 = sqrt(c);//a2=3,向下取整且强制转化为int型printf("a1:%d\n",a1);//3printf("a2:%d\n",a2);//3}