LeeCode from 0 —— 69. Sqrt(x)

Posted ssml

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeeCode from 0 —— 69. Sqrt(x)相关的知识,希望对你有一定的参考价值。

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);
}
};








以上是关于LeeCode from 0 —— 69. Sqrt(x)的主要内容,如果未能解决你的问题,请参考以下文章