mirror of
https://github.com/krahets/hello-algo.git
synced 2025-01-23 22:40:25 +08:00
Fix access error when printArray(arr, 0) (#432)
* fix(codes/cpp): Memory leak fix: the space was not freed when pop removed the element. * fix(codes/cpp): Fix access error when printArray(arr, 0) * Update PrintUtil.hpp --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
parent
e539c44f63
commit
b9e97d3823
@ -102,7 +102,7 @@ class PrintUtil {
|
|||||||
for (int i = 0; i < n - 1; i++) {
|
for (int i = 0; i < n - 1; i++) {
|
||||||
cout << arr[i] << ", ";
|
cout << arr[i] << ", ";
|
||||||
}
|
}
|
||||||
if (n>=1)
|
if (n >= 1)
|
||||||
cout << arr[n - 1] << "]" << endl;
|
cout << arr[n - 1] << "]" << endl;
|
||||||
else
|
else
|
||||||
cout << "]" << endl;
|
cout << "]" << endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user