恒生电子笔试题3

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Pay attention:Don't answer on the sheet, please answer on the blank answer-sheet.

1.Specify what does “func()” do with the list "ppList", and what are the errors.

struct NODE

{

int nValue;

struct NODE* pLeft;

struct NODE* pRight;

};

struct NODE_LIST

{

const struct NODE* pNode;

struct NODE_LIST* pNext;

};

struct NODE_LIST* sub_func(const struct NODE* pTree, struct NODE_LIST* pList) {

if (pList == NULL)

{

pList = malloc(sizeof(struct NODE_LIST));

if (pList == NULL)

{

return 0;

}

pList->pNode = pTree;

pList->pNext = NULL;

return pList;

}

else

{

while (pList->pNext)

{

pList = pList->pNext;

}

pList->pNext = malloc(sizeof(struct NODE_LIST));

if (pList->pNext == NULL)

{

return 0;

}

pList->pNext->pNode = pTree;

pList->pNext->pNext = NULL;

return pList->pNext;

}

}

int func(const struct NODE* pTree, struct NODE_LIST** ppList)

{

int nNum = 0;

if (pTree == NULL)

{

return nNum;

}

else

{

struct NODE_LIST* pNew = sub_func(pTree, *ppList);

int nTemp = 0;

if (pTree->pLeft != NULL)

{

nTemp += func(pTree->pLeft, &pNew);

if (pNew == NULL)

{

return -1;

}

}

if (pTree->pRight != NULL)

{

nTemp += func(pTree->pRight, &pNew);

if (pNew == NULL)

{

return -1;

}

}

return nTemp + 1;

}

}

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.Given a decimal number, return the number in string of specified base (The base of a system

of numbers, such as 2 in the binary system and 10 in the decimal system). The base is bigger than 1 and less than 10. For example, the given number is 99 in decimal, and return string “143” of base 8 (don't use any C standard function, except malloc() ).

char* GetNumber(unsigned int nNum, unsigned int nBase)

{

}

4.Find a path from start position to end position in maze. The maze's width is 8, and height is

8 too, it is expressed by an two-dimensional array, the start position of it is left-up corner

and its coordinate is (0, 0), and the end position is right-down corner and coordinate (7, 7).

Each integer element in array defines connectivity of a block, 0 if disconnected, others

connected. For example, a path is painted in different color in the following maze expressed

相关文档
最新文档