代码简洁性
作者:
hunterooo
,
2024-03-16 19:49:57
,
所有人可见
,
阅读 16
代码片段
public static void eval(){
int b = num.pop();
int a = num.pop();
char c = op.pop();
if(c == '+') num.push(a + b);
else if(c == '-') num.push(a - b);
else if(c == '*') num.push(a * b);
else num.push(a / b);
}
======>>>>>>>>>>
public static void eval(){
int b = num.pop();
int a = num.pop();
char c = op.pop();
int x = 0;
if(c == '+') x = a + b;
else if(c == '-') x = a - b;
else if(c == '*') x = a * b;
else x = a / b;
num.push(x);
}
注意代码的简洁性!!!!!