<i id='9KE2I'><tr id='9KE2I'><dt id='9KE2I'><q id='9KE2I'><span id='9KE2I'><b id='9KE2I'><form id='9KE2I'><ins id='9KE2I'></ins><ul id='9KE2I'></ul><sub id='9KE2I'></sub></form><legend id='9KE2I'></legend><bdo id='9KE2I'><pre id='9KE2I'><center id='9KE2I'></center></pre></bdo></b><th id='9KE2I'></th></span></q></dt></tr></i><div id='9KE2I'><tfoot id='9KE2I'></tfoot><dl id='9KE2I'><fieldset id='9KE2I'></fieldset></dl></div>

      <small id='9KE2I'></small><noframes id='9KE2I'>

        <bdo id='9KE2I'></bdo><ul id='9KE2I'></ul>

      <legend id='9KE2I'><style id='9KE2I'><dir id='9KE2I'><q id='9KE2I'></q></dir></style></legend>

      1. <tfoot id='9KE2I'></tfoot>
      2. 带有数学运算符的字符串到整数

        时间:2023-05-28
        <tfoot id='0niDD'></tfoot>
          <bdo id='0niDD'></bdo><ul id='0niDD'></ul>

          • <small id='0niDD'></small><noframes id='0niDD'>

            • <i id='0niDD'><tr id='0niDD'><dt id='0niDD'><q id='0niDD'><span id='0niDD'><b id='0niDD'><form id='0niDD'><ins id='0niDD'></ins><ul id='0niDD'></ul><sub id='0niDD'></sub></form><legend id='0niDD'></legend><bdo id='0niDD'><pre id='0niDD'><center id='0niDD'></center></pre></bdo></b><th id='0niDD'></th></span></q></dt></tr></i><div id='0niDD'><tfoot id='0niDD'></tfoot><dl id='0niDD'><fieldset id='0niDD'></fieldset></dl></div>
                <tbody id='0niDD'></tbody>
              <legend id='0niDD'><style id='0niDD'><dir id='0niDD'><q id='0niDD'></q></dir></style></legend>

                  本文介绍了带有数学运算符的字符串到整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有数学运算符的字符串,我需要将其转换为 int(答案).

                  I have a string with math operators which I need to turn into an int (the answer).

                  以下代码不起作用,但我不确定如何使 answer 变量起作用.

                  The below code does not work, but I'm not sure how I can get the answer variable to work.

                  String question;
                  int answer;
                  
                  question = "7/7+9-9*5/5";
                  answer = Integer.parseInt(question);
                  

                  推荐答案

                  Integer.parseInt(question); ...要是这么简单就好了...

                  Integer.parseInt(question); ... If only it was so simple ...

                  "7/7+9-9*5/5"="nofollow">中缀表示法 您要评估并将结果打印给用户.这样做的方法是将其转换为 后缀表示法,也称为反向波兰表示法,使用 调车场算法.将表达式转换为后缀评估后,使用此算法

                  You have there a mathematical expression "7/7+9-9*5/5" in infix notation which you want to evalutate and print the result to the user. The way to do that is to convert it to postfix notation also known as Reverse Polish notation using the Shunting-yard algorithm. Once you have converted the expression to postfix evaluating is pretty easy using this algorithm

                  这篇关于带有数学运算符的字符串到整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Java int 部门让我感到困惑 下一篇:Integer.parseInt(String str) java.lang.NumberFormatException

                  相关文章

                  <tfoot id='41v3F'></tfoot>

                1. <small id='41v3F'></small><noframes id='41v3F'>

                  1. <legend id='41v3F'><style id='41v3F'><dir id='41v3F'><q id='41v3F'></q></dir></style></legend>
                  2. <i id='41v3F'><tr id='41v3F'><dt id='41v3F'><q id='41v3F'><span id='41v3F'><b id='41v3F'><form id='41v3F'><ins id='41v3F'></ins><ul id='41v3F'></ul><sub id='41v3F'></sub></form><legend id='41v3F'></legend><bdo id='41v3F'><pre id='41v3F'><center id='41v3F'></center></pre></bdo></b><th id='41v3F'></th></span></q></dt></tr></i><div id='41v3F'><tfoot id='41v3F'></tfoot><dl id='41v3F'><fieldset id='41v3F'></fieldset></dl></div>
                      <bdo id='41v3F'></bdo><ul id='41v3F'></ul>