Introduction to C # direct insertion sorting

Source: Internet
Author: User

C # direct insertion sorting

Basic Idea: insert the size of the key code of the record to be sorted in sequence to the appropriate position of the sorted record subsequence. The number of records in the subsequence increases from 1. When the number of records in the subsequence is in the first order, the number of records in the table is sorted at the same time.

C # Insert the Sorting Code directly:

 
 
  1. ///<Summary> 
  2. /// Insert the sorting algorithm directly
  3. /// Summary> 
  4. PublicclassDirectInsertSort: IAction
  5. {
  6.  
  7. # RegionIAction Member
  8.  
  9. PublicvoidAction ()
  10. {
  11. Int []Array=Program. RandomArray ();
  12. For (Inti=1; I<Array. Length; I ++)
  13. {
  14. If (array [I]<Array[I-1])
  15. {
  16. Inttem=Array[I];
  17. Intj=0;
  18. For (J=I-1; j>= 0 & tem<Array[J]; j --)
  19. {
  20. Array [j + 1] = array [j];
  21. }
  22. Array [j + 1] = tem;
  23. }
  24. }
  25. }
  26. # Endregion
  27. }

The preceding section describes how to directly insert and sort data in C.

  1. C # Call Windows API functions
  2. C # Calling Outlook APIs
  3. C # connect to Access and SQL Server databases
  4. Introduction to C # API call problems
  5. C # Call Excel and additional code

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.