提问:java变量
网友回答:
因为大写字母A对应的值为0x41,而Z对应的是0x5a
所以可以这样
public static void main(String[]args) { int a = 50; int b = 90; int c = 88; int d = 120; int e = 67; int score = 0; if (a >= 0x41 && a <= 0x5a) score += 10; else score -= 5; if (b >= 0x41 && b <= 0x5a) score += 10; else score -= 5; if (c >= 0x41 && c <= 0x5a) score += 10; else score -= 5; if (d >= 0x41 && d <= 0x5a) score += 10; else score -= 5; if (e >= 0x41 && e <= 0x5a) score += 10; else score -= 5; System.out.println(score); }
结果为20
(手工算也可以的)