满意答案
qq40777000
.08.31
采纳率:59%等级:12
已帮助:7910人
public class MapTest {
public static void main(String[] args) {
Map map = new HashMap();
map.put("壹", 1);
map.put("贰", 2);
map.put("叁", 3);
map.put("肆", 4);
map.put("伍", 5);
map.put("陆", 6);
map.put("柒", 7);
map.put("捌", 8);
map.put("玖", 9);
String str = "肆+伍";// 我们就假设是这个样式的
int a = map.get(str.substring(0, 1));
char b = str.charAt(1);
int c = map.get(str.substring(2, 3));
switch (b) {
case '+':
System.out.println(a + c);
break;
case '-':
System.out.println(a - c);
break;
case '*':
System.out.println(a * c);
break;
case '/':
System.out.println(a / c);
break;
default:
System.out.println("未定义的符号");
}
}
}
这是一个小小的例子,给你一条路走,具体的逻辑需要你自己去修正
00分享举报