mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			972 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			972 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Write methods to implement the multiply, subtract, and divide operations for integers. The results of all of these are integers. Use only the add operator.</p>
 | 
						|
 | 
						|
<p>You should implement following methods:</p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>Operations()</code>  constructor</li>
 | 
						|
	<li><code>minus(a, b)</code>  Subtraction, returns <code>a - b</code></li>
 | 
						|
	<li><code>multiply(a, b)</code>  Multiplication, returns <code>a * b</code></li>
 | 
						|
	<li><code>divide(a, b)</code>  Division, returns <code>a / b</code></li>
 | 
						|
</ul>
 | 
						|
 | 
						|
<p><strong>Example: </strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
Operations operations = new Operations();
 | 
						|
operations.minus(1, 2); //returns -1
 | 
						|
operations.multiply(3, 4); //returns 12
 | 
						|
operations.divide(5, -2); //returns -2
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Note: </strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li>You can assume inputs are always valid, that is, e.g., denominator will not be 0 in division.</li>
 | 
						|
	<li>The number of calls will not exceed 1000.</li>
 | 
						|
</ul>
 |