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)/计算器 [calculator-lcci].html
2022-03-29 12:43:11 +08:00

28 lines
879 B
HTML
Raw 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>表达式仅包含非负整数,<code>+</code> <code>-</code> <code>*</code><code>/</code> 四种运算符和空格&nbsp;<code>&nbsp;</code>。 整数除法仅保留整数部分。</p>
<p><strong>示例&nbsp;1:</strong></p>
<pre><strong>输入: </strong>&quot;3+2*2&quot;
<strong>输出:</strong> 7
</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入:</strong> &quot; 3/2 &quot;
<strong>输出:</strong> 1</pre>
<p><strong>示例 3:</strong></p>
<pre><strong>输入:</strong> &quot; 3+5 / 2 &quot;
<strong>输出:</strong> 5
</pre>
<p><strong>说明:</strong></p>
<ul>
<li>你可以假设所给定的表达式都是有效的。</li>
<li><strong>不要</strong>使用内置的库函数 <code>eval</code></li>
</ul>