- 10 Ağu 2019
- 985
- 17
Kod:
[FONT=monospace][COLOR=#BC7A00]#include[/COLOR] [COLOR=#408080][I]<stdio.h>[/I][/COLOR][COLOR=#BC7A00][/COLOR][/FONT]
[FONT=monospace][COLOR=#BC7A00] #include[/COLOR] [COLOR=#408080][I]<stdlib.h>[/I][/COLOR][COLOR=#BC7A00][/COLOR][/FONT]
[FONT=monospace][COLOR=#BC7A00] #include[/COLOR] [COLOR=#408080][I]<time.h>[/I][/COLOR][COLOR=#BC7A00][/COLOR][/FONT]
[FONT=monospace][COLOR=#BC7A00] #include[/COLOR] [COLOR=#408080][I]<math.h>[/I][/COLOR][COLOR=#BC7A00][/COLOR][/FONT]
[FONT=monospace][COLOR=#BC7A00] [/COLOR][/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR][/FONT]
[FONT=monospace] [COLOR=#0000FF]sum_of_digits[/COLOR] ([COLOR=#B00040]int[/COLOR] number)[/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] temp [COLOR=#666666]=[/COLOR] number;[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] sum [COLOR=#666666]=[/COLOR] [COLOR=#666666]0[/COLOR];[/FONT]
[FONT=monospace] [COLOR=#008000][B]while[/B][/COLOR] (temp)[/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] sum [COLOR=#666666]+=[/COLOR] temp [COLOR=#666666]%[/COLOR] [COLOR=#666666]10[/COLOR];[/FONT]
[FONT=monospace] temp [COLOR=#666666]/=[/COLOR] [COLOR=#666666]10[/COLOR];[/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#008000][B]return[/B][/COLOR] sum;[/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR][/FONT]
[FONT=monospace] [COLOR=#0000FF]first_segment[/COLOR]()[/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] xxxxx;[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] xxx_min [COLOR=#666666]=[/COLOR][COLOR=#666666]1[/COLOR], xxx_max [COLOR=#666666]=[/COLOR] [COLOR=#666666]366[/COLOR];[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] last_two_min [COLOR=#666666]=[/COLOR] [COLOR=#666666]3[/COLOR], last_two_max [COLOR=#666666]=[/COLOR] [COLOR=#666666]95[/COLOR];[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] xxx [COLOR=#666666]=[/COLOR] xxx_min [COLOR=#666666]+[/COLOR] rand() [COLOR=#666666]%[/COLOR] (xxx_max[COLOR=#666666]-[/COLOR]xxx_min);[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] last_two [COLOR=#666666]=[/COLOR] last_two_min [COLOR=#666666]+[/COLOR] rand() [COLOR=#666666]%[/COLOR] (last_two_max [COLOR=#666666]-[/COLOR] last_two_min);[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] xxxxx [COLOR=#666666]=[/COLOR] (xxx [COLOR=#666666]*[/COLOR] [COLOR=#666666]100[/COLOR]) [COLOR=#666666]+[/COLOR] last_two;[/FONT]
[FONT=monospace] [COLOR=#008000][B]return[/B][/COLOR] xxxxx; [/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR][/FONT]
[FONT=monospace] [COLOR=#0000FF]third_segment[/COLOR] ()[/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] xxxxx;[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] sum;[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] last;[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#008000][B]do[/B][/COLOR] [/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] xxxxx [COLOR=#666666]=[/COLOR] rand() [COLOR=#666666]%[/COLOR] [COLOR=#666666]99999[/COLOR];[/FONT]
[FONT=monospace] sum [COLOR=#666666]=[/COLOR] sum_of_digits(xxxxx);[/FONT]
[FONT=monospace] last [COLOR=#666666]=[/COLOR] [COLOR=#666666]7[/COLOR][COLOR=#666666]-[/COLOR](sum[COLOR=#666666]%[/COLOR][COLOR=#666666]7[/COLOR]);[/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [COLOR=#008000][B]while[/B][/COLOR](last [COLOR=#666666]==[/COLOR] [COLOR=#666666]0[/COLOR] [COLOR=#666666]||[/COLOR] last [COLOR=#666666]==[/COLOR] [COLOR=#666666]8[/COLOR]);[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#008000][B]return[/B][/COLOR] xxxxx [COLOR=#666666]*[/COLOR] [COLOR=#666666]10[/COLOR] [COLOR=#666666]+[/COLOR] last;[/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR][/FONT]
[FONT=monospace] [COLOR=#0000FF]fourth_segment[/COLOR]()[/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] xxxxx;[/FONT]
[FONT=monospace] xxxxx [COLOR=#666666]=[/COLOR] rand() [COLOR=#666666]%[/COLOR] [COLOR=#666666]99999[/COLOR];[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#008000][B]return[/B][/COLOR] xxxxx;[/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR][/FONT]
[FONT=monospace] [COLOR=#0000FF]main[/COLOR]()[/FONT]
[FONT=monospace] {[/FONT]
[FONT=monospace] srand(time([COLOR=#008000]NULL[/COLOR]));[/FONT]
[FONT=monospace] [COLOR=#B00040]int[/COLOR] first_seg, third_seg, fourth_seg;[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] first_seg [COLOR=#666666]=[/COLOR] first_segment();[/FONT]
[FONT=monospace] third_seg [COLOR=#666666]=[/COLOR] third_segment();[/FONT]
[FONT=monospace] fourth_seg [COLOR=#666666]=[/COLOR] fourth_segment();[/FONT]
[FONT=monospace] printf([COLOR=#BA2121]"%05d-OEM-%07d-%04d"[/COLOR],first_seg, third_seg,fourth_seg);[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [COLOR=#008000][B]return[/B][/COLOR] EXIT_SUCCESS;[/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] [/FONT]
[FONT=monospace] }[/FONT]
[FONT=monospace] [/FONT]