<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>亂數 on Lin's Blog</title><link>http://coder.tw/tags/%E4%BA%82%E6%95%B8/</link><description>Recent content in 亂數 on Lin's Blog</description><generator>Hugo</generator><language>zh-tw</language><lastBuildDate>Sun, 05 Jun 2011 01:00:07 +0000</lastBuildDate><atom:link href="http://coder.tw/tags/%E4%BA%82%E6%95%B8/index.xml" rel="self" type="application/rss+xml"/><item><title>洗牌演算法（交換法）</title><link>http://coder.tw/posts/shuffle-algorithm-swap-method/</link><pubDate>Sun, 05 Jun 2011 01:00:07 +0000</pubDate><guid>http://coder.tw/posts/shuffle-algorithm-swap-method/</guid><description>&lt;p&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/06/2011-06-05_005920.jpg"&gt;&lt;img class="size-large wp-image-534 aligncenter" title="2011-06-05_005920" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/06/2011-06-05_005920-540x352.jpg" alt="" width="540" height="352" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;洗牌演算法就是可以產生不重複的亂數的一種演算法，舉例來講如果要產生十個亂數，並且這十個亂數必須是「不重複」的，那很多人的直覺是用rand函式取得一個亂數值以後，存入陣列，並且跟陣列內以有的數字做比對，這種方法簡單是簡單，但是效能很差，而這裡要介紹的洗牌演算法效能跟剛剛講的方法可說是天差地遠，洗牌演算法的原理其實很簡單，就是先在陣列裡存入數字，然後將數字打散&lt;/p&gt;</description></item></channel></rss>