Skip to content

Commit 010c93a

Browse files
authored
Merge pull request #57 from QSCTech-Sange/main
fix: cpp_tricks 中地板除的数字错误typo
2 parents 0dd85de + 97a9865 commit 010c93a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/cpp_tricks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ std::wstring utf8_to_wstring(std::string const &s) {
8888

8989
```cpp
9090
int a = 14, b = 5;
91-
int c = a / b; // c = 14 / 5 = 3
91+
int c = a / b; // c = 14 / 5 = 2
9292
```
9393

9494
等价于
9595

9696
```cpp
97-
int c = floor((float)a / b); // c = floor(2.8) = 3
97+
int c = floor((float)a / b); // c = floor(2.8) = 2
9898
```
9999

100100
如果 `a` 除以 `b` 除不尽,那么会找到比他大的第一个整数作为结果,这就是**地板除 (floor div)**

0 commit comments

Comments
 (0)