Your break statements will exit the for loops prematurely.

if (num == distinct[x])

At this point, distinct[x] is emtpy for all indexes in the array.