题干解读:要求将输入函数的平方根返回
解题思路:使用cmath库中的sqrt函数即可.
#include <cmath>
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
* 求非负整数 n 的平方根
* @param n int整型 你需要求 n 的平方根
* @return double浮点型
*/
double findSqrt(int n) {
double s = sqrt(n);
return s;
// write code here
}
};

京公网安备 11010502036488号