mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
20 lines
941 B
HTML
20 lines
941 B
HTML
|
<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>
|