@Frank:
You should rethink your algorithm.
Here's how I solved this: Think of it like a modified Bubble Sort, except you're not really sorting the elements in any order, just making the negative values "bubble up" to the end of the array. The idea is to iterate through the array and swap a negative number with the next non-negative number. The most tricky part is finding the index of the next non-negative number and guarding against referencing an index that is out of bounds.
The alternative algorithm allows you to eliminate one level of nesting inside the loop.
So for tab = { 25, 3, 5, -1, 4, 12, -1, -1, 21, 7, -1 }, here's how it would go:
first iteration, i = 0
skip to next iteration because tab[0] is positive (25)
next iteration, i = 1
skip to next iteration because tab[1] is positive (3)
next iteration, i = 2
skip to next iteration because tab[2] is positive (5)
next iteration, i = 3
don't skip because tab[3] is negative (-1)
find the index j greater than i such that tab[j] is positive (4)
that means j == 4
swap tab[3] and tab[4]
now, tab[3] == 4 and tab[4] == -1
next iteration, i = 4
don't skip because tab[4] is negative (-1)
find the index j greater than i such that tab[j] is positive (12)
that means j == 5
swap tab[4] and tab[5]
now, tab[4] == 12 and tab[5] == -1
next iteration, i = 5
don't skip because tab[5] is negative (-1)
find the index j greater than i such that tab[j] is positive (21)
that means j == 8
swap tab[5] and tab[8]
now, tab[5] == 21 and tab[8] == -1
... and so on