比如我输入这样一个字符串:123*12-45+56/45  获取这个字符串之后,怎么处理计算出结果~~~

解决方案 »

  1.   

    用JavaScript的话 那叫一个方便
      

  2.   

    Famous global IT company 上海
    Position: Senior Java Software Engineer
    Business Unit: Famous global IT company - BAS - China - ITSEResponsibilities
     Lead the development of complex software product and mobile applications. 
     Design layered application, including user interface, business functionality, and database access. 
     Work with other engineers, managers, product managers, QA, and operation teams to develop innovative solutions that meet et needs with respect to functionality, performance, scalability, and reliability while meeting realistic implementation schedules and adhering to development goals and principles. 
     Estimate engineering efforts, plan implementations, and rollout system changes. 
     Share release management duties during feature rollouts and share on-call responsibilities. 
     Developing, unit testing, maintenance and release of software products under Agile patterns.
     Experience in developing highly scalable applications a major plus. 
    Job Requirements 
     BS/BA in CS or related field. 
     5+ years experience in requirements analysis, design, coding and testing of scalable, distributed, fault-tolerant applications.
     Expertise required in object-oriented design methodology and enterprise application development in Java . 
     Hands-on experience with J2EE/J2SE application. 
     Hands-on experience in Agile projects.
     Good at OO methodology, and familiar with Java design patterns.
     Proven result-oriented person with a delivery focus in a fast pace, high quality environment.
     Self-motivated and work under pressure.
     Solid capabilities of self study for new technologies.
     Knowledge of software product development is a major plus
     Fluent English in both speaking and writing.有意者加MSN:[email protected]
      

  3.   

    可以用beanshell
    如果是1.6的话直接用javax.script就可以
      

  4.   

    JDK1.6的话,用javax.script很简单,要是别的话,就麻烦了
      

  5.   

    http://ruyuntao.javaeye.com/blog/406935
      

  6.   

    package com.xuz.csdn.june16;import javax.script.ScriptEngine;
    import javax.script.ScriptEngineManager;
    import javax.script.ScriptException;
    public class ScriptEngineTest { public static void main(String[] args) {
    ScriptEngineManager sem = new ScriptEngineManager();
    ScriptEngine se = sem.getEngineByName("js");
    try {
    System.out.println(se.eval("1+2*(3+4)").toString());
    } catch (ScriptException e) {
    e.printStackTrace();
    }
    }}
      

  7.   

    如果是自己写算法的话,就可以利用堆栈来算。
    有2个stack一个放数字,另一个放运算符号+-*/()。
    然后确定运算符优先级是+-*/()。
    然后依次把表达式放到2个stack里面,遇到优先级低的就把数字stack里面的2个和运算符号stack里面拿出来进行计算,再把结果push到数字stack.