import java.util.Scanner;
public class Count {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s = scanner.nextLine().trim();
if (s.isEmpty()) {
print(0);
}
String[] nums = s.replace("-", " -")
.replace("+", " ").split(" ");
Integer counts = 0;
for (int i = 0; i < nums.length; i++) {
String temp = nums[i];
int thisNum;
final boolean sub;
if (temp.contains("-")) {
sub = true;
temp = temp.replace("-", "");
} else
sub = false;
if (temp.startsWith("0x")) {
thisNum = Integer.parseInt(temp.replace("0x", ""), 16);
} else if (temp.startsWith("0")) {
thisNum = Integer.parseInt(temp, 8);
} else {
thisNum = Integer.parseInt(temp);
}
if (sub) {
counts -= thisNum;
} else {
counts += thisNum;
}
}
print(counts);
}
public static void print(Object o) {
System.out.println(o);
}
}
我也来写一下