I think the problem is with the minCount variable. It is set to the value of i and at the exchange part (line 186 to 187) you aren't really exchanging, because i and minCount are indexing the same object. I think the exchange part should be
1 2 3
temp = ptr[i];
ptr[i] = ptr[j];
ptr[j] = temp;
I think you should also get rid of minCount since it serves the same purpose as i
I think the problem is with the minCount variable. It is set to the value of i and at the exchange part (line 186 to 187) you aren't really exchanging, because i and minCount are indexing the same object. I think the exchange part should be
1 2 3
temp = ptr[i];
ptr[i] = ptr[j];
ptr[j] = temp;
I think you should also get rid of minCount since it serves the same purpose as i
The thing with that is if I used ptr[j] to swap it, that's outside of the inner for loop and therefore j would be uninitialized.
Looking at some documentation for a selection sort your sort is not quite correct. You may want to review your documentation for this sort. Here is the link I used:
Looking at some documentation for a selection sort your sort is not quite correct. You may want to review your documentation for this sort. Here is the link I used:
@slimdog Why did you delete the contents of your earlier posts? That makes this thread useless as a learning resource for the other users of this forum.
Please edit your posts to reinstate their original contents, so that this can be read and understood by others.