How to realize C++ numerical random seed
This article introduces the relevant knowledge of "how to achieve C++ numerical random seed". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
# include
# include
Whole Lord ()
{
Seed sequence sequence ({1, 2, 3, 4, 5})
Vector seed (10)
Sequence. To produce (a seed). Start (), seed. Tail ()
/ / step 1: fill with 0x8b8b8b8b
/ / seed = {2341178251, 2341178251, 2341178251, 2341178251,2341178251
/ / 2341178251, 2341178251, 2341178251, 2341178251, 2341178251}
/ /
/ / step 2:
/ / n = 10, s = 5, t = 3, p = 3, Q = 6, m = 10
/ /
/ / first iteration, k = 0; R1 = 1371501266, R2 = 1371501271
/ /
/ / seed = {1371501271, 2341178251, 2341178251, 37126795172341178251
/ / 2341178251, 3712679522, 2341178251, 2341178251, 2341178251}
/ /
/ / iterations from k = 1 to k = 5 (R2 = R1 + k% n + v [k-1])
/ /
/ / R1 = 2786190137, 3204727651, 4173325571, 1979226628401983366
/ / R2 = 2786190139, 3204727655, 4173325577, 1979226636401983376
/ /
/ / seed = {3350727907, 3188173515, 3204727655, 4173325577, 1979226636
/ / 401983376, 3591037797, 2811627722, 1652921976, 2219536532}
/ /
/ / iterations from k = 6 to k = 9 (R2 = R1 + k% n)
/ /
/ / R1 = 2718637909, 1378394210, 2297813071, 1608643617
/ / R2 = 2718637915, 1378394217, 2297813079, 1608643626
/ /
/ / seed = {434154821, 1191019290, 3237041891, 1256752498,4277039715
/ / 2010627002, 2718637915, 1378394217, 2297813079, 1608643626}
/ /
/ / step 3
/ / iterate from k = 10 to k = 19 and modify the output with ^ =
/ /
/ / R1 = 1615303485, 3210438310, 893477041, 2884072672, 1918321961
/ / R2 = 1615303485, 3210438309, 893477039, 2884072669,1918321957
/ /
/ / seed = {303093272, 3210438309, 893477039, 2884072669,1918321957
/ / 1117182731, 1772877958, 2669970405, 3182737656, 4094066935}
/ /
/ / R1 = 423054846, 46783064, 3904109085, 1534123446, 1495905687
/ / R2 = 423054841, 46783058, 3904109078, 15341234381495905678
/ /
/ / seed = {4204997637, 4246533866, 1856049002, 1129615051,690460811
/ / 1075771511, 46783058, 3904109078, 1534123438, 1495905678}
Yes (positive 32 _ t n: seed)
Output