#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void generate_numbers_that_include_specific_digit_x_times(int N, int xtims, int digit, int rndtimes, int to) {
srand(time(NULL));
int total_numbers = 0;
for (int i = 1; i <= rndtimes; i++) {
int n = rand() % to + 1;
int copy_n = n;
int count = 0;
if (N == total_numbers) {
return;
}
while (n > 0) {
if (n % 10 == digit)
count++;
n = n / 10;
}
if (count == xtims) {
total_numbers++;
printf("%d\n", copy_n);
}
}
}
int main(void)
{
generate_numbers_that_include_specific_digit_x_times(5, 3, 7, 2000, 1000000);
return 0;
}
/*
run:
776367
995777
752177
727472
775970
*/