Skip to content

Commit 3df9567

Browse files
committed
Fix Listing 3.3
1 parent 118c3c7 commit 3df9567

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

_posts/2024-08-15-addendum.markdown

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ tags: Addendum
88

99
It does not matter how often one proofreads the book, there will be always bugs in the code or some issues. We will document the issues here and update the code on [GitHub](https://github.com/ModernCPPBook/Examples). Of course, we will update the potential new release of the book accordingly.
1010

11+
## Chapter 3
12+
13+
[Listing 3.3](https://github.com/ModernCPPBook/Examples/blob/main/notebooks/Chapter_3.ipynb) the cases for even and odd are wrong in the code and should be chnaged to
14+
15+
{% highlight c++ %}
16+
if (values.size() % 2 == 0) {
17+
median = *mid; |\label{container:median:list:defref}|
18+
} else {
19+
auto mid_one = values.begin();
20+
std::advance(mid_one, mid_index + 1);
21+
median = 0.5 * (*mid + *mid_one);
22+
}
23+
{% endhighlight %}
1124

1225
## Chapter 15
1326

0 commit comments

Comments
 (0)