恒生电子

简介: 1.    Please specify what does “func()” do with the list "pParam", and what are the errors. struct LIST  {      int nValue;      struct LIST * pPr...

1.    Please specify what does “func()” do with the list "pParam", and what are the errors.

struct LIST 

    int nValue; 
    struct LIST * pPrev; 
    struct LIST * pNext; 
}; 
struct LIST * func(struct LIST * pParam) 

    struct LIST* pCur = pParam; 
    struct LIST* pNext; 
    struct LIST* pPrev = NULL; 
    struct LIST* pTail; 
    struct LIST* pReturn = NULL;

    if (pCur == NULL) 
    { 
        return pReturn; 
    } 
    else 
    { 
        pPrev = pCur->pPrev; 
        if (pCur->pNext == NULL) 
        { 
             pReturn = pCur; 
        } 
        else 
        { 
             pReturn = pCur->pNext; 
        } 
    }

    while (pCur != NULL) 
    { 
        pNext = pCur->pNext; 
        if (pNext == NULL) 
        { 
            return pReturn; 
        } 
        else 
        { 
            pTail = pNext->pNext;

            pNext->pPrev = pPrev; 
            pNext->pNext = pCur; 
            pCur->pPrev = pNext; 
            if (pTail == NULL) 
            { 
                pCur->pNext = pTail; 
            } 
            else 
            { 
                if (pTail->pNext == NULL) 
                { 
                    pCur->pNext = pTail; 
                } 
                else 
                { 
                    pCur->pNext = pTail->pNext; 
                } 
            } 
        }

        pPrev = pCur; 
        pCur = pTail; 
    }

    return pReturn; 

2.    Please complete the standard C function: memmove(), here is the description (don’t use any C standard function): 
void * memmove (void *to, const void *from, unsigned int size) 
memmove copies the size bytes at from into the size bytes at to. The value returned by memmove is the value of to. 
3.    please complete this function, get binary tree’s depth. For example, the following binary tree’s depth is 4. The function returns depth. 
   1 
/     \ 
2    3 
     /       \ 
   4          5 
/     \ 
6        7

struct NODE 

    struct NODE* pLeft;        // pLeft is NULL if it has no left sub node 
    struct NODE* pRight;    // pRight is NULL if it has no right sub node 
}; 
int GetDepth(const struct NODE* pRoot) 

}

4.    A worker needs to do A work and B work. B’s priority is higher than A. For example, if he shall do A from 9:00 to 13:00, and shall doing B from 10:00 to 11:00, his choice shall be doing A from 9:00 to 10:00, doing B from 10:00 to 11:00, and doing A from 11:00 to 13:00.

Complete the following function (you can use pseudo-code or solution steps explanation instead of actual code), ”pSchedule“ is a worker’s work schedule (it’s an array), "nNum" is number of elements in array "pSchedule", "ppResult" is the result array which shall be returned and its buffer shall be allocated by yourself, "nRNum" is number of elements in “ppResult". The time phases in "pSchedule" cover each other, and not sorted, the output data in "ppResult" shall be a new schedule that are not covered of any phase, and sorted by start time. Return 0 if success.

enum WORK 

    A,        // A work 
    B        // B work 
}; 
struct SCHED 

    int nStartHour;        // at that hour work start 
    int nEndHour;            // at that hour work end 
    enum WORK work;        // work type 
}; 
int func(const struct SCHED* pSchedule, unsigned int nNum, struct SCHED** ppResult, unsigned int& nRNum) 

}

1.    请指出以下函数对参数"pParam"做了什么动作,并指出其中的错误

    将链表中的元素奇数位与偶数位互换。

int func(struct LIST * pParam) 

    // … … 
    while (pCur != NULL) 
    { 
        pNext = pCur->pNext; 
        if (pNext == NULL) 
        { 
            pCur->pPrev = pPrev; 
            return pReturn; 
        } 
        // … … 
    } 
    return pReturn; 
}

2.    请完成标准C函数:memmove()

void *memmove(void *dest, const void *src, size_t count) 

    char *tmp; 
    const char *s;

    if (dest == NULL || src == NULL) 
    { 
        return NULL; 
    }

    if (dest <= src) { 
        tmp = dest; 
        s = src; 
        while (count–) 
            *tmp++ = *s++; 
    } else { 
        tmp = dest; 
        tmp += count; 
        s = src; 
        s += count; 
        while (count–) 
            *–tmp = *–s; 
    } 
    return dest; 
}

3.    请完成以下函数,返回二叉树的深度。例如下面所示二叉树的深度为4。

#include <stdlib.h>

struct NODE 

    struct NODE* pLeft;    // pLeft is NULL if it has no left sub node 
    struct NODE* pRight;    // pRight is NULL if it has no right sub node 
};

int GetDepth(const struct NODE* pRoot) 

    if (pRoot == NULL) 
    { 
        return 0; 
    } 
    int nLeft = GetDepth(pRoot->pLeft); 
    int nRight = GetDepth(pRoot->pRight); 
    return nLeft > nRight ? nLeft + 1 : nRight + 1; 
}

4.    工人需要做A工作和B工作。B工作的优先级比A工作更高。例如,如果他要在9:00至13:00做A工作,而且在10:00至11:00做B工作,那么他 应该在9:00至10:00做A工作,在10:00至11:00做B工作,在11:00至13:00做A工作。 
完成下面函数,"pSchedule"是工人的工作计划(它是一个数组),"nNum"是数组"pSchedule"中的元素数量,"ppResult" 是需要返回的结果数组,"nRNum"是结果中的元素数量。"pSchedule"中的时间段互相覆盖,而且未排序,输出结果"ppResult"中的时 间段不允许有覆盖,并且按开始时间排序。函数执行成功返回0。


//以下是2011年的笔试题

5、已知2010年的1月1日是星期五,写一个函数,输入M年和N 月,计算出该月的第3个星期五是几号?


6、写SQL 语句的题,其中有一个是如何创建索引?

答案:(http://www.cnblogs.com/hanjin/archive/2008/09/09/1287505.html

 

转自:http://www.cnblogs.com/cswolf/archive/2011/10/13/2267124.html  

img_e00999465d1c2c1b02df587a3ec9c13d.jpg
微信公众号: 猿人谷
如果您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】
如果您希望与我交流互动,欢迎关注微信公众号
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

相关文章
|
4天前
|
云安全 人工智能 自然语言处理
|
9天前
|
人工智能 Java API
Java 正式进入 Agentic AI 时代:Spring AI Alibaba 1.1 发布背后的技术演进
Spring AI Alibaba 1.1 正式发布,提供极简方式构建企业级AI智能体。基于ReactAgent核心,支持多智能体协作、上下文工程与生产级管控,助力开发者快速打造可靠、可扩展的智能应用。
839 24
|
3天前
|
机器学习/深度学习 人工智能 自然语言处理
Z-Image:冲击体验上限的下一代图像生成模型
通义实验室推出全新文生图模型Z-Image,以6B参数实现“快、稳、轻、准”突破。Turbo版本仅需8步亚秒级生成,支持16GB显存设备,中英双语理解与文字渲染尤为出色,真实感和美学表现媲美国际顶尖模型,被誉为“最值得关注的开源生图模型之一”。
409 3
|
12天前
|
数据采集 人工智能 自然语言处理
Meta SAM3开源:让图像分割,听懂你的话
Meta发布并开源SAM 3,首个支持文本或视觉提示的统一图像视频分割模型,可精准分割“红色条纹伞”等开放词汇概念,覆盖400万独特概念,性能达人类水平75%–80%,推动视觉分割新突破。
814 59
Meta SAM3开源:让图像分割,听懂你的话
|
1天前
|
弹性计算 网络协议 Linux
阿里云ECS云服务器详细新手购买流程步骤(图文详解)
新手怎么购买阿里云服务器ECS?今天出一期阿里云服务器ECS自定义购买流程:图文全解析,阿里云服务器ECS购买流程图解,自定义购买ECS的设置选项是最复杂的,以自定义购买云服务器ECS为例,包括付费类型、地域、网络及可用区、实例、镜像、系统盘、数据盘、公网IP、安全组及登录凭证详细设置教程:
169 114
|
5天前
|
机器学习/深度学习 人工智能 数据可视化
1秒生图!6B参数如何“以小博大”生成超真实图像?
Z-Image是6B参数开源图像生成模型,仅需16GB显存即可生成媲美百亿级模型的超真实图像,支持中英双语文本渲染与智能编辑,登顶Hugging Face趋势榜,首日下载破50万。
355 19
|
2天前
|
人工智能 安全 小程序
阿里云无影云电脑是什么?最新收费价格个人版、企业版和商业版无影云电脑收费价格
阿里云无影云电脑是运行在云端的虚拟电脑,分企业版和个人版。企业版适用于办公、设计等场景,4核8G配置低至199元/年;个人版适合游戏、娱乐,黄金款14元/月起。支持多端接入,灵活按需使用。
246 164