1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-03-14 16:22:24 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/x 的平方根 [jJ0w9p].html

35 lines
1007 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个非负整数 <code>x</code> ,计算并返回 <code>x</code> 的平方根,即实现&nbsp;<code>int sqrt(int x)</code>&nbsp;函数。</p>
<p>正数的平方根有两个,只输出其中的正数平方根。</p>
<p>如果平方根不是整数,输出只保留整数的部分,小数部分将被舍去。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong> x = 4
<strong>输出:</strong> 2
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong> x = 8
<strong>输出:</strong> 2
<strong>解释:</strong> 8 的平方根是 2.82842...,由于小数部分将被舍去,所以返回 2
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><meta charset="UTF-8" /><code>0 &lt;= x &lt;= 2<sup>31</sup>&nbsp;- 1</code></li>
</ul>
<p>&nbsp;</p>
<p><meta charset="UTF-8" />注意:本题与主站 69&nbsp;题相同:&nbsp;<a href="https://leetcode-cn.com/problems/sqrtx/">https://leetcode-cn.com/problems/sqrtx/</a></p>