标签:compute ant art mys sqrt nbsp ret git c++
69. Sqrt(x)
Implement int sqrt(int x)
.
Compute and return the square root of x, where x is guaranteed to be a non-negative integer.
Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.
C++代码如下:
class Solution {
public:
int mySqrt(int x) {
double s;
s=sqrt(x);
return int(s);
}
};
标签:compute ant art mys sqrt nbsp ret git c++
原文地址:https://www.cnblogs.com/ssml/p/9302088.html