C # Data Structure sorting algorithm, which includes Bubble sorting. For more information, see Lao Zhao's CodeTimer and eaglet performance counters. Thank you ~~
Let's get started with our sorting algorithm ~
Before performing the C # Data Structure sorting algorithm, we first define a 100-bit random sequence to test the performance of various C # Data Structure sorting algorithms.
The Code is as follows:
- ///<Summary>
- /// Randomly generate an array of 100 bits
- /// Summary>
- ///<Returns>Returns the generated array. Returns>
- Publicstaticint [] RandomArray ()
- {
- Randomran=NewRandom();
- Int []Arr=Newint[100];
- Inttem;
- For (Inti=0; I<100; I ++)
- {
- Tem=Ran. Next (1,100 );
- Arr [I] = tem;
- }
- Returnarr;
- }
Bubble Sort)
Basic Idea: Compare key codes of adjacent records. If the key codes recorded earlier are greater than the key codes recorded later, they are exchanged. Otherwise, they are not exchanged.
- ///<Summary>
- /// Bubble Sorting Algorithm
- /// Summary>
- PublicclassBubbleSort: IAction
- {
- # RegionIAction Member
- PublicvoidAction ()
- {
- Int []Array=Program. RandomArray ();
- For (Inta=0;<Array. Length; A ++)
- {
- Intitem=0;
- For (Intb=Array. Length-1; B>A; B --)
- {
- If (array [B]<Array[B-1])
- {
- Item=Array[B];
- Array [B] = array [b-1];
- Array [b-1] = item;
- }
- }
- }
- }
- # Endregion
- }
- C # Call Windows API functions
- C # Calling Outlook APIs
- C # connect to Access and SQL Server databases
- Introduction to C # API call problems
- C # Call Excel and additional code