int m = 5;
int n = 7;
int x = (m*8/(n+2))%m;
System.out.println("m:" + m);
System.out.println("n:" + n);
System.out.println("x:" + x);
m:5
n:7
x:4
这里不是先算括号内的加法,然后m*8/n+2,再取余吗?为什么我算出来答案不一样呢。求指导
额,是自己糊涂了
n+2 = 9;
m * 8 = 40;
40 / 9 = 4;
4 % m = 4;
不对吗?