I've got a pretty good link. The code here should help you out
Heapsort.
The code here is a little easy to identify that it's not yours, so try changing it so it compiles in C++, but isn't recognizable as it's original code, pseudo. Combined it's code with your code to come up with unique code for solving this problem.
Also, a word of advice. Never ever use j, k or any single character as a variable name. Always spell out in descriptive words what it is. I usually use my first word as all lowercase, and all other words as initial caps. Like if I wanted a variable for counting through the indexes of an array called myArray, my variable would be: int myArrayIndex, or int myArrayCount, or something. Describe what each variable does, and document your code with comments as well!
I'm not trying to bash you, but I have no way of knowing what's going on in your code...
Post your code again after you do this by renaming your variables with understandable names, and commenting in what each part is trying to do--using my link to cheat/understand what's going on with your code.
Also tell us what class you are doing this for. Asking for help on homework without specifying it's homework is against forum rules :)
Hopefully Helpful,
TamusJRoyce
"Writing code is like combining Algebra, Logic, and Book Writing with a much easier grammar to understand"