I am doing a hw assignment which is a puzzle game and i came to this problem.

I have a 2d array and i have a set of numbers lets say (ex:1-100)

I need to place these numbers randomely in the array.

I initially tried to user srand() and rand() to fill the array with numbers upto 100 but it repeat numbers some times. so it doesn't work.

This is what I have now. Thankx in advance guys. have a good day

Code:for (i=0;i<need_num;i++) { srand(i); b=rand()%need_num; // random number with in need_num //temp storing the rand # in a array temp temp_array[i]=b; } i=0; //filling actual array, we leav the emptyspaces as 0's at the end of the //array for(n=0;n<dim;n++){ for(m=0;m<dim;n++){ array[n][m]=temp_array[i]; i++; } } }