The point of the Sword 14: Adjust the order of the array so that the odd digits precede the even number

Source: Internet
Author: User

#include <stdio.h>voidOddaheadofeven (intArray[],intStartintend) {    intLastoddindex = start-1;  for(intindex=start;index<=end;index++)    {        if(array[index]&0x01) {Lastoddindex++; inttemp =Array[lastoddindex]; Array[lastoddindex]=Array[index]; Array[index]=temp; }            }}voidPrintArray (intArray[],intnumssize) {printf ("\nprintf Array begin---------------------\ n");  for(intindex =0; index<numssize;index++) {printf ("%d \ t", Array[index]); } printf ("\nprintf Array end-----------------------\ n"); }voidTest () {intArray[] = {1, +,3,542, +,5,2,6, About,4,6,7,2}; intNumssize =sizeof(array)/sizeof(int);        PrintArray (array,numssize); Oddaheadofeven (Array,0, numssize-1);        PrintArray (array,numssize); }intMainvoid) {    //your code goes heretest (); return 0;}

Http://ideone.com/mnYx0V

The point of the Sword 14: Adjust the order of the array so that the odd digits precede the even number

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.