使用方法:
#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);//3
printf("a2:%d\n",a2);//3
}
版权声明:本文为qq_44671121原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。