Can someone help me?Could someone help me write this Random10Numbers function?
Why this code can only output two lines of random numbers? I want to generate four lines, each line contains ten and the single line of random numbers does not repeat #include <stdio.h> #include <stdlib.h> #include <time.h> int index = 0; int counter[10] = {0}; int count = 1; void Random10Numbers(int *numbers,int size){ int random_num; if(count == size + 1){ count = 0; index = 0; for(int i = 0;i < size;i++){ counter[i] = 0; numbers[i] = 0; } } do{ random_num = rand() % 10; }while(counter[random_num]); counter[random_num]++; numbers[index++] = random_num; count++; } int main(){ srand(time(0)); int data[10]; int i,j; for(i=0;i<4;i++){ for(j=0;j<10;j++){ Random10Numbers(data,10); printf("%d ",data[j]); } printf("\n"); } return 0; }