1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/计算器(English) [calculator-lcci].html

31 lines
876 B
HTML

<p>Given an arithmetic equation consisting of positive integers, +, -, * and / (no paren&shy;theses), compute the result.</p>
<p>The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should truncate toward zero.</p>
<p><strong>Example&nbsp;1:</strong></p>
<pre>
<strong>Input: </strong>&quot;3+2*2&quot;
<strong>Output:</strong> 7
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> &quot; 3/2 &quot;
<strong>Output:</strong> 1</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> &quot; 3+5 / 2 &quot;
<strong>Output:</strong> 5
</pre>
<p><strong>Note:</strong></p>
<ul>
<li>You may assume that the given expression is always valid.</li>
<li>Do not use the eval built-in library function.</li>
</ul>