Insert sorting directly and sort by hill

Source: Internet
Author: User

Insert sorting directly and sort by hill
Why is the code similar !!

/* Name: InsertSortCopyright: Author: huowolf Date: 05/07/15 16: 18 Description: directly Insert the sorting implementation */# include
 
  
Using namespace std; int arr [] = {-, 98}; void InsertSort (int a [], int length ); void Output (int a [], int length); int main () {InsertSort (arr, 8); Output (arr, 8); return 0 ;} void InsertSort (int a [], int length) {int I, j; for (I = 2; I <= length; I ++) {if (a [I]
  
/* Name: ShellSort Copyright: Author: huowolf Date: 05/07/15 16: 18 Description: Implementation of hill sorting */# include
   
    
Using namespace std; int arr [] = {-, 98}; void ShellSort (int a [], int length ); void Output (int a [], int length); int main () {ShellSort (arr, 8); Output (arr, 8); return 0 ;} void ShellSort (int a [], int length) {int I, j; int d = length; // initialize the incremental value to do {d = d/3 + 1; // incremental sequence (a classic incremental method without providing the optimum proof) for (I = d + 1; I <= length; I ++) {if (a [I] 0 & a [0] 1); // increment to 1, stop loop} void Output (int a [], int length) {for (int I = 1; I <= length; I ++) cout <
    

 

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.