C # implementation shuffling algorithm

Source: Internet
Author: User

C # Shuffle algorithm, simple demo!

<summary>///Shuffle algorithm///</summary>private void Test () {  int[] icards = new int[54];  for (int i = 0; i < icards.length; i++)  {    Icards[i] = i + 1;  }  Random rand = new Random ();  int itarget = 0, icardtemp = 0;  for (int i = 0; i < icards.length; i++)  {    itarget = rand. Next (0, icards.length);    Icardtemp = Icards[i];    Icards[i] = Icards[itarget];    Icards[itarget] = icardtemp;  }  for (int i = 0; i < icards.length; i++)  {    Response.Write ("+" + (i + 1) + "cards are:" + icards[i] + "<br/>");  }}

The above is the paper to share the entire content of the shuffle algorithm, I hope you can like.

In addition to the Declaration,Running GuestArticles are original, reproduced please link to the form of the address of this article
C # implementation shuffling algorithm

This address: http://www.paobuke.com/develop/c-develop/pbk23099.html






Related content asp: Control permissions in the view C # Simple read, change file creation, modification, and access time the difference between property and attribute in C # How to convert a DataTable in C #
C # Implement a method similar to Sina Weibo long URL to short address C # Multithreading Learning (ii) How to manipulate a thread the generic delegate instance of C # Basics Tutorial C # Implementation of image grayscale technology

C # implementation shuffling algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.