在这种情况下,百分比是指什么?
int myInt = 27 % 10;
myInt = 7;
Run Code Online (Sandbox Code Playgroud)
%这段代码的意思是什么?
%表示余数,当27除以10时余数为7
EDIT:
Run Code Online (Sandbox Code Playgroud)
关于模数和余数之间差异的所有讨论我的2美分
拿一个%b
1. When both +ve, Modulo & Remainder are one and the same
2. When a is -ve, they are not the same
Run Code Online (Sandbox Code Playgroud)
例如;
a = -10,b = 3
剩余-10%3 = -1
对于Modulo,在'a'中加上3的倍数并计算余数.
-10 + 12 = 2
2%3 = 2是你的答案
| 归档时间: |
|
| 查看次数: |
2006 次 |
| 最近记录: |