Advertisement
Vvardenfell
Feb 9th, 2024 (edited)
54
1
Never
This is comment for paste 02. Remove Negatives and Reverse
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ptr[j] = ptr[j + 1]; is an out of bounds access if it's only the last element in the array that is negative. the oob access can be avoided by changing the condition in for (int j = i; j < n; j++) to j < n-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement