mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>实现 <a href="https://www.cplusplus.com/reference/valarray/pow/" target="_blank">pow(<em>x</em>, <em>n</em>)</a> ,即计算 <code>x</code> 的整数 <code>n</code> 次幂函数(即,<code>x<sup>n</sup></code><sup><span style="font-size:10.8333px"> </span></sup>)。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong class="example">示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>x = 2.00000, n = 10
 | 
						||
<strong>输出:</strong>1024.00000
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong class="example">示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>x = 2.10000, n = 3
 | 
						||
<strong>输出:</strong>9.26100
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong class="example">示例 3:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>x = 2.00000, n = -2
 | 
						||
<strong>输出:</strong>0.25000
 | 
						||
<strong>解释:</strong>2<sup>-2</sup> = 1/2<sup>2</sup> = 1/4 = 0.25
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>-100.0 < x < 100.0</code></li>
 | 
						||
	<li><code>-2<sup>31</sup> <= n <= 2<sup>31</sup>-1</code></li>
 | 
						||
	<li><code>n</code> 是一个整数</li>
 | 
						||
	<li>要么 <code>x</code> 不为零,要么 <code>n > 0</code> 。</li>
 | 
						||
	<li><code>-10<sup>4</sup> <= x<sup>n</sup> <= 10<sup>4</sup></code></li>
 | 
						||
</ul>
 |