

Kod:
#include
#include
#include
#include
int
sum_of_digits (int number)
{
int temp = number;
int sum = 0;
while (temp)
{
sum += temp % 10;
temp /= 10;
}
return sum;
}
int
first_segment()
{
int xxxxx;
int xxx_min =1, xxx_max = 366;
int last_two_min = 3, last_two_max = 95;
int xxx = xxx_min + rand() % (xxx_max-xxx_min);
int last_two = last_two_min + rand() % (last_two_max - last_two_min);
xxxxx = (xxx * 100) + last_two;
return xxxxx;
}
int
third_segment ()
{
int xxxxx;
int sum;
int last;
do
{
xxxxx = rand() % 99999;
sum = sum_of_digits(xxxxx);
last = 7-(sum%7);
}
while(last == 0 || last == 8);
return xxxxx * 10 + last;
}
int
fourth_segment()
{
int xxxxx;
xxxxx = rand() % 99999;
return xxxxx;
}
int
main()
{
srand(time(NULL));
int first_seg, third_seg, fourth_seg;
first_seg = first_segment();
third_seg = third_segment();
fourth_seg = fourth_segment();
printf("%05d-OEM-%07d-%04d",first_seg, third_seg,fourth_seg);
return EXIT_SUCCESS;
}