📜  如何将字符转换为运算符 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:10.305000             🧑  作者: Mango

代码示例1
int Compute(char c, int a, int b)
{
    switch (c) {  
    case '+': return a+b;
    case '-': return a-b;
    case '*': return a*b;
    case '/': return a/b;
    default: throw std::runtime_error("No such operator");
    }
}