Coding Horror: The Danger of Naïveté é åã®ä¸èº«ãã©ã³ãã ãªé åºã«ã·ã£ããã«ããã³ã¼ããæ¸ããããåç´ã§ããããåãããããã¦ééãã®ç¡ãã³ã¼ããæ¸ãããä¾ãã°ï¼ãããªæãã«â¦â¦ for (int i = 0; i < cards.Length; i++) { int n = rand.Next(cards.Length); Swap(ref cards[i], ref cards[n]); } ããã¯åç´ã§åãããããï¼ ã§ãæ®å¿µï¼ ãã®ã³ã¼ãã¯ééã£ã¦ãããã·ã£ããã«å¾ã®é åºã«åããåºã¦ãã¾ããæ£è§£ã¯ãã¡ãã for (int i = cards.Length - 1; i > 0; i--) { int n = rand.Next(i + 1); Swap(ref cards[i], ref cards[n]); } ã±ã£ã¨è¦ã¦éããåããï¼ ã¤ã³
{{#tags}}- {{label}}
{{/tags}}