C/C++中开平方函数sqrt()的用法

开平方使用sqrt()函数

使用方法:

包含于math.h头文件

sqrt(float * number),返回number的开平方数,返回值为浮点型


sqrt使用时大多需要要强制类型转化,因为sqrt只支持double和float类型,
可以这样
c=(int) sqrt((double)a*a+b*b);

或者
c=(int) sqrt((float)a*a+b*b);

 

原文地址:https://www.cnblogs.com/ybqjymy/p/12375824.html