#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void generate_numbers_that_include_specific_digit_x_times(int xtims, int digit, int rndtimes, int to) {
srand(time(NULL));
for (int i = 1; i <= rndtimes; i++) {
int n = rand() % to + 1;
int copy_n = n;
int count = 0;
while (n > 0) {
if (n % 10 == digit)
count++;
n = n / 10;
}
if (count == xtims) {
printf("%d\n", copy_n);
}
}
}
int main(void)
{
generate_numbers_that_include_specific_digit_x_times(3, 7, 2000, 1000000);
return 0;
}
/*
run:
7784767
272767
773837
147677
776547
716747
777063
778790
478717
967773
207767
779478
577378
272477
474727
677987
870737
7707
738477
947779
578707
747057
748077
247737
76727
907077
734177
775475
767713
777500
171771
77078
*/