if (currIndex < 0) {
cout << currIndex << " % " << array.size() << endl;
currIndex = currIndex % array.size();
cout << currIndex << endl;
}
Run Code Online (Sandbox Code Playgroud)
输出:
-1 % 3
0
Run Code Online (Sandbox Code Playgroud)
-1 % 3 = -1 在 C++ 中,为什么返回 0?
完整片段:https : //ideone.com/leWqhi
| 归档时间: |
|
| 查看次数: |
37 次 |
| 最近记录: |