{"id":67744,"date":"2017-02-23T02:05:05","date_gmt":"2017-02-22T18:05:05","guid":{"rendered":"http:\/\/www.xiaoyebailong.com\/?p=67744"},"modified":"2017-02-26T02:09:01","modified_gmt":"2017-02-25T18:09:01","slug":"asp%e7%94%9f%e6%88%90%e9%9a%8f%e6%9c%ba%e6%95%b0%e5%87%bd%e6%95%b0-randomize%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2017\/02\/23\/67744.htm","title":{"rendered":"Asp\u751f\u6210\u968f\u673a\u6570\u51fd\u6570 randomize\u7684\u4f7f\u7528"},"content":{"rendered":"<p>\u51fd\u6570rnd\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u51fd\u6570\u3002\u5982\u679c\u4f60\u60f3\u5efa\u7acb\u4e00\u4e2a\u968f\u673a\u7684\u95ee\u5019\u8bed\uff0c\u4e00\u4e2a\u65e5\u671f\u7684\u968f\u673a\u63d0\u793a\uff0c\u6216\u8005\u751a\u81f3\u4e00\u4e2a\u6e38\u620f\uff0c\u4f60\u5c06\u8981\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u3002<\/p>\n<p>\u51fd\u6570rnd\u8fd4\u56de\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6570\u3002\u8fd9\u91cc\u6709\u8fd9\u4e2a\u51fd\u6570\u7684\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; %=rnd()%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u5176\u53ef\u80fd\u7684\u8fd4\u56de\u503c\uff1a<\/p>\n<blockquote><p>0.7055645<\/p><\/blockquote>\n<p>\u5178\u578b\u60c5\u51b5\u4e0b\uff0c\u4f60\u66f4\u611f\u5174\u8da3\u7684\u662f\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u8fd4\u56de\u5904\u5728\u4e00\u5b9a\u8303\u56f4\u5185\u7684\u6574\u6570\u3002\u8981\u8fd4\u56de\u4e00\u4e2a\u5927\u4e8e\u7b49\u4e8e0\u800c\u5c0f\u4e8e\u67d0\u4e2a\u7279\u5b9a\u6574\u6570\u7684\u6570\u5b57\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u8bed\u53e5\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; %=int((upperbound+1)*rnd)%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u7528\u4f60\u60f3\u4ea7\u751f\u7684\u6700\u5927\u968f\u673a\u6570\u4ee3\u66ff\u8868\u8fbe\u5f0fupperbound\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u811a\u672c\u8fd4\u56de\u4e00\u4e2a0\u548c5\u4e4b\u95f4\u7684\u6570\uff0c\u5305\u62ec0\u548c5\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; %=int(5+1)*rnd)%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u5982\u679c\u4f60\u60f3\u4ea7\u751f\u4e00\u4e2a\u5904\u5728\u67d0\u4e2a\u8303\u56f4\u5185\u7684\u968f\u673a\u6570\uff0c\u8be5\u8303\u56f4\u6709\u4e00\u4e2a\u5927\u4e8e0\u7684\u4e0b\u754c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u811a\u672c\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; %=int((upperbound - lowerbound + 1)*rnd+lowerbound)%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u811a\u672c\u4ea7\u751f\u4e00\u4e2a50\u523075\u4e4b\u95f4\u7684\u968f\u673a\u6570\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; %=int((75-50+1)*rnd+50)%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u65e0\u8bba\u4f55\u65f6\u4f7f\u7528\u51fd\u6570rnd\uff0c\u5b83\u5c06\u4ee5\u540c\u6837\u7684\u987a\u5e8f\u8fd4\u56de\u540c\u6837\u7684\u968f\u673a\u6570\uff0c\u8fd9\u4e5f\u8bb8\u53e6\u4f60\u5403\u60ca\u3002<br \/>\n\u8003\u8651\u5982\u4e0b\u7684\u4f8b\u5b50\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; % \r\npick_greeting=int((2+1)*rnd) \r\nselect case pick_greeting \r\ncase 0 \r\ngreeting=\"welcome!\" \r\ncase 1 \r\ngreeting=\"hello!\" \r\ncase 2 \r\ngreeting=\"happy to see you!\" \r\nend select \r\n%&gt; \r\n&lt; %=greeting%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u8fd9\u4e2a\u811a\u672c\u5efa\u7acb\u5e76\u6253\u5370\u4e00\u4e2a\u968f\u673a\u7684\u95ee\u5019\u8bed\u3002<br \/>\n\u4f46\u662f\uff0c\u5b83\u6709\u53ef\u80fd\u5e76\u4e0d\u6309\u4f60\u60f3\u8c61\u7684\u65b9\u5f0f\u5de5\u4f5c\u3002<br \/>\n\u65e0\u8bba\u4f55\u65f6\u6709\u4eba\u4e0b\u8f7d\u4e86\u5305\u542b\u8fd9\u6bb5\u811a\u672c\u7684\u7f51\u9875\uff0c\u5c06\u6709\u540c\u6837\u7684\u968f\u673a\u95ee\u5019\u8bed\u88ab\u6253\u5370\u3002<br \/>\n\u5982\u679c\u6709\u4eba\u591a\u6b21\u56de\u5230\u8fd9\u4e2a\u7f51\u9875\uff0c\u4ed6\u6216\u5979\u5c06\u5f97\u5230\u540c\u6837\u7684\u95ee\u5019\u3002\u4e00\u4e2a\u968f\u673a\u6570\u4ea7\u751f\u4e86\uff0c\u4f46\u662f\u6bcf\u6b21\u90fd\u662f\u540c\u6837\u7684\u968f\u673a\u6570\u3002<br \/>\n\u6709\u4e00\u4e2a\u7279\u6b8a\u7684\u8bed\u53e5\u53ef\u4ee5\u5e2e\u52a9\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<br \/>\nrandomize\u8bed\u53e5\u7528\u6765\u5f3a\u5236\u51fd\u6570rnd\u4f7f\u7528\u4e00\u4e2a\u65b0\u7684\u968f\u673a\u6570\u5e8f\u5217\u3002randomize\u8bed\u53e5\u901a\u8fc7\u8ba1\u7b97\u673a\u7684\u7cfb\u7edf\u8ba1\u65f6\u5668\uff0c\u4e3a\u51fd\u6570rnd\u63d0\u4f9b\u4e00\u4e2a\u65b0\u7684\u79cd\u5b50\u503c\u3002<br \/>\n\u6700\u540e\uff0c\u5982\u679c\u4f60\u5bf9\u51fd\u6570rnd\u6240\u4ea7\u751f\u7684\u6570\u503c\u7684\u5206\u5e03\u611f\u5230\u597d\u5947\uff0c\u4f60\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u811a\u672c\u6765\u786e\u5b9a\u5b83\uff1a<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"asp\">&lt; % \r\nconst upperbound=9,iterations=100 \r\nredim dist(upperbound) \r\nrandomize \r\nfor i=1 to iterations \r\nrnd_num=int((upperbound+1)*rnd) \r\ndist(rnd_num)=dist(rnd_num)&amp;\"#\" \r\nnext \r\nfor i=0 to upperbound \r\n%&gt; \r\n&lt; %=i&amp;\":\"&amp;dist(i)%&gt;&lt;br \/&gt; \r\n&lt; %next%&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u8fd9\u6bb5\u811a\u672c\u57280\u52309\u4e4b\u95f4\u4ea7\u751f100\u4e2a\u968f\u673a\u6570\u3002\u5b83\u8ddf\u8e2a\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u503c\u6709\u591a\u5c11\u4e2a\u968f\u673a\u6570\u4ea7\u751f\u3002<br \/>\n\u6700\u540e\uff0c\u5b83\u6253\u5370\u4e00\u4e2a\u4ee3\u8868\u7ed3\u679c\u7684\u6761\u5f62\u56fe\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51fd\u6570rnd\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u51fd\u6570\u3002\u5982\u679c\u4f60\u60f3\u5efa\u7acb\u4e00\u4e2a\u968f\u673a\u7684\u95ee\u5019\u8bed\uff0c\u4e00\u4e2a\u65e5\u671f\u7684\u968f\u673a\u63d0\u793a\uff0c\u6216\u8005\u751a\u81f3\u4e00\u4e2a\u6e38\u620f\uff0c\u4f60\u5c06\u8981\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u3002 \u51fd\u6570rnd\u8fd4\u56de\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6570\u3002\u8fd9\u91cc\u6709\u8fd9\u4e2a\u51fd\u6570\u7684\u4e00\u4e2a\u4f8b\u5b50\uff1a 1 &lt; %=rnd()%&gt; \u5176\u53ef\u80fd\u7684\u8fd4\u56de&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[12,260,261],"topic":[],"class_list":["post-67744","post","type-post","status-publish","format-standard","hentry","category-htmlcss","category-technology","tag-asp","tag-randomize","tag-261"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/67744","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=67744"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/67744\/revisions"}],"predecessor-version":[{"id":67745,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/67744\/revisions\/67745"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=67744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=67744"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=67744"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=67744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}