惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
B
Blog RSS Feed
Last Week in AI
Last Week in AI
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Security Blog
Microsoft Security Blog
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
雷峰网
雷峰网
C
Check Point Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
博客园 - 司徒正美
U
Unit 42
量子位

博客园 - HonestMan

面试百问 o,1的感悟 公司内部推荐 debain oracle insert method a linked list, find the node that the last node point to. Get balance noe Memory - HonestMan - 博客园 ShuffleMerge---microsoft's interview question 新手开始学习linux print all Permutation of a string Google, hire me How to interview a programmer? Binary search tree convert to double linked list. Search in Binary tree spilt a list wirte a function for counting a linked list length Remove repeat char from a string
An funy question!
HonestMan · 2007-09-21 · via 博客园 - HonestMan

Q: An int array, devide an array of integers into two parts, odd in the first part, and even in the second part.

We need some sub Function:
1: IsEven(int n) // n is Even or not
2: void Reorder(int *pData, unsigned int length, bool (*func)(int));

void Reorder(int *pData, unsigned int length, bool (*func)(int))
{
    if (Null==pData || length==0)
        return;
    //
    int *Pbegin = pData;
    int *Pend = pdata+length-1;
    //
    while(Pbegin<Pend)
    {
        if(!func(*Pbegin))
        {
            Pbegin++;
            continue;
        }
        //
        if(func(*Pend))
        {
            Pend--;
            continue;
        }
        //Swap
        int temp;
        temp = * Pbegin;
        *Pbegin = *Pend;
        *Pend = temp;
    }    

}

bool IsEven(int n)
{
    return(n&1)==0;
}

void ReorderOddEven(int *pData, unsigned int length)
{
      Reorder(pData, length, isEven);
}