灵感来自javascript论坛,经过自己的改进,应该说是比较完美了:

function yunsuan(a,op,b)
{
    try
    {
        eval("result=" + a+ op + b);
        return result;
    }
    catch(e)
    {
        alert("err");
    }
}
function main()
{

    var a,b,s;
    a =prompt("please input a number?");
    s = prompt("输入运算符");
    b = prompt("please input another number?");

    alert(yunsuan(a,s,b));
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-10-13
  • 2021-12-19
  • 2021-11-27
猜你喜欢
  • 2021-12-02
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2021-12-02
相关资源
相似解决方案