{"id":1787,"date":"2026-06-07T00:17:32","date_gmt":"2026-06-06T16:17:32","guid":{"rendered":"http:\/\/wordpress.fangt.online\/?p=1787"},"modified":"2026-06-07T00:19:14","modified_gmt":"2026-06-06T16:19:14","slug":"%e9%9a%8f%e6%9c%ba%e6%95%b0%ef%bc%88random-number%ef%bc%89","status":"publish","type":"post","link":"http:\/\/wordpress.fangt.online\/index.php\/2026\/06\/07\/%e9%9a%8f%e6%9c%ba%e6%95%b0%ef%bc%88random-number%ef%bc%89\/","title":{"rendered":"\u968f\u673a\u6570\uff08Random Number\uff09"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u968f\u673a\u6570\u5728\u8ba1\u7b97\u673a\u79d1\u5b66\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u89d2\u8272\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e<strong>\u6a21\u62df\u3001\u62bd\u6837\u3001\u6e38\u620f\u3001\u5bc6\u7801\u5b66\u3001\u673a\u5668\u5b66\u4e60\u3001\u7b97\u6cd5\u8bbe\u8ba1<\/strong>\uff08\u5982\u968f\u673a\u5316\u5feb\u901f\u6392\u5e8f\uff09\u7b49\u9886\u57df\u3002<br>\u8ba1\u7b97\u673a\u672c\u8eab\u662f\u786e\u5b9a\u6027\u7684\u7cfb\u7edf\uff0c\u56e0\u6b64\u901a\u5e38\u751f\u6210\u7684\u662f<strong>\u4f2a\u968f\u673a\u6570<\/strong>\u2014\u2014\u770b\u4f3c\u968f\u673a\u4f46\u5b9e\u9645\u7531\u786e\u5b9a\u7b97\u6cd5\u4ea7\u751f\u7684\u5e8f\u5217\u3002\u5728\u67d0\u4e9b\u9ad8\u5b89\u5168\u8981\u6c42\u573a\u666f\uff08\u5982\u5bc6\u94a5\u751f\u6210\uff09\u5219\u9700\u8981<strong>\u771f\u968f\u673a\u6570<\/strong>\uff0c\u6765\u6e90\u4e8e\u7269\u7406\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u968f\u673a\u6570\u7684\u7c7b\u578b<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>\u7c7b\u578b<\/th><th>\u63cf\u8ff0<\/th><th>\u6765\u6e90<\/th><th>\u53ef\u5426\u91cd\u73b0<\/th><th>\u5178\u578b\u7528\u9014<\/th><\/tr><\/thead><tbody><tr><td>\u771f\u968f\u673a\u6570<\/td><td>\u57fa\u4e8e\u7269\u7406\u566a\u58f0\u3001\u91cf\u5b50\u6548\u5e94\u3001\u70ed\u566a\u58f0\u7b49\u4e0d\u53ef\u9884\u6d4b\u73b0\u8c61<\/td><td>\u786c\u4ef6\u968f\u673a\u6570\u53d1\u751f\u5668\uff08HRNG\uff09<\/td><td>\u4e0d\u53ef\u91cd\u73b0<\/td><td>\u5bc6\u7801\u5b66\u3001\u5f69\u7968\u3001\u4e00\u6b21\u4e00\u5bc6<\/td><\/tr><tr><td>\u4f2a\u968f\u673a\u6570<\/td><td>\u7531\u6570\u5b66\u7b97\u6cd5\u4ea7\u751f\u7684\u786e\u5b9a\u6027\u5e8f\u5217\uff0c\u4f46\u901a\u8fc7\u7edf\u8ba1\u6d4b\u8bd5<\/td><td>\u4f2a\u968f\u673a\u6570\u751f\u6210\u5668\uff08PRNG\uff09<\/td><td>\u53ef\u91cd\u73b0\uff08\u7ed9\u5b9a\u79cd\u5b50\uff09<\/td><td>\u6a21\u62df\u3001\u6e38\u620f\u3001\u8499\u7279\u5361\u6d1b\u65b9\u6cd5<\/td><\/tr><tr><td>\u5bc6\u7801\u5b66\u5b89\u5168\u4f2a\u968f\u673a\u6570<\/td><td>\u6ee1\u8db3\u989d\u5916\u4e0d\u53ef\u9884\u6d4b\u6027\u8981\u6c42\u7684PRNG\uff0c\u5373\u4f7f\u66b4\u9732\u90e8\u5206\u8f93\u51fa\u4e5f\u96be\u4ee5\u63a8\u65ad\u524d\u540e\u503c<\/td><td>CSPRNG\uff08\u5982ChaCha20\u3001AES-CTR\uff09<\/td><td>\u53ef\u91cd\u73b0\uff08\u79cd\u5b50\u4fdd\u5bc6\uff09<\/td><td>\u4f1a\u8bdd\u5bc6\u94a5\u3001\u968f\u673a\u6570Nonce<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u968f\u673a\u6570\u5b9e\u73b0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream>\n#include &lt;ctime>\n#include &lt;cstdlib>\nusing namespace std;\nint main() {\n   srand(time(0)); \/\/ \u4f7f\u7528\u5f53\u524d\u65f6\u95f4\u4f5c\u4e3a\u79cd\u5b50\n   cout&lt;&lt;rand(); \/\/ \u751f\u6210\u968f\u673a\u6570\n   return 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8303\u56f4\u516c\u5f0f\uff1a\u968f\u673a\u751f\u6210a\uff5eb\u4e4b\u95f4\u7684\u968f\u673a\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>rand() % (b - a + 1) + a;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u9ed8\u8ba4\u8303\u56f4\uff1arand() \u7684\u9ed8\u8ba4\u8303\u56f4\u89c6\u7cfb\u7edf\u800c\u5b9a0\uff5e32767\u62162147483647<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u673a\u6570\u5728\u8ba1\u7b97\u673a\u79d1\u5b66\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u89d2\u8272\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6a21\u62df\u3001\u62bd\u6837\u3001\u6e38\u620f\u3001\u5bc6\u7801\u5b66\u3001\u673a\u5668\u5b66\u4e60\u3001\u7b97\u6cd5\u8bbe\u8ba1\uff08\u5982\u968f\u673a\u5316\u5feb\u901f\u6392\u5e8f\uff09 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-1787","post","type-post","status-publish","format-standard","hentry","category-zl"],"_links":{"self":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/comments?post=1787"}],"version-history":[{"count":3,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1787\/revisions"}],"predecessor-version":[{"id":1790,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1787\/revisions\/1790"}],"wp:attachment":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/media?parent=1787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/categories?post=1787"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/tags?post=1787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}