Each time you recursively call main()
, you create a new array bk
.
The information you entered in the previous invocation of main()
is hidden from the new one.
- To iterate is human; to recurse, divine.
In this context, give up divinity for humanity. Use iteration — in this context it is better.
This is your primary problem; there may also be other off-by-one or other errors.