1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/运算 [operations-lcci].html
2022-03-29 12:43:11 +08:00

20 lines
941 B
HTML
Raw Permalink 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>请实现整数数字的乘法、减法和除法运算,运算结果均为整数数字,程序中只允许使用加法运算符和逻辑运算符,允许程序中出现正负常数,不允许使用位运算。</p>
<p>你的实现应该支持如下操作:</p>
<ul>
<li><code>Operations()</code> 构造函数</li>
<li><code>minus(a, b)</code> 减法,返回<code>a - b</code></li>
<li><code>multiply(a, b)</code> 乘法,返回<code>a * b</code></li>
<li><code>divide(a, b)</code> 除法,返回<code>a / b</code></li>
</ul>
<p><strong>示例:</strong></p>
<pre>Operations operations = new Operations();
operations.minus(1, 2); //返回-1
operations.multiply(3, 4); //返回12
operations.divide(5, -2); //返回-2
</pre>
<p><strong>提示:</strong></p>
<ul>
<li>你可以假设函数输入一定是有效的例如不会出现除法分母为0的情况</li>
<li>单个用例的函数调用次数不会超过1000次</li>
</ul>