The adjustment array of the sword means the odd number is preceded by even (question 14)

Source: Internet
Author: User




1 /****************************************                                                                                                        2      > File Name:test.c  3     >  author:xiaoxiaohui  4     > mail:[email protected]   5     > created time:2016 May 26   Thursday  19 15 minutes, 12 seconds   6  ********************/  7   8  #include <stdio.h>  9  #include <assert.h> 10  11 void adjust (int *array, int size)  12  { 13     assert (array);  14     assert (size  > 0); 15  16     int* left = arrar;  17     int* right = arrar[size - 1]; 18  19      while (Right > left)  20     { 21          if (  (*left)  & 1)  == 0)     //left for even  22         { 23              if (  (*right)  & 1) &NBSP;==&NBSP;1)   Odd  24             { 25  on the right                 swap (*left,  *right); 26                  left++; 27                  right--; 28              } 29             else  30             { 31                  right--; 32              } 33          } 34         else      //If the left is not an even number, Then left++ 35         { 36              left++; 37          } 38     } 39 }


This article is from "Narcissus" blog, please make sure to keep this source http://10704527.blog.51cto.com/10694527/1783645

The adjustment array of the sword means the odd number is preceded by even (question 14)

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.