- 论坛徽章:
- 0
|
本帖最后由 magicboatrocket 于 2010-11-08 11:14 编辑
某公司的笔试题,不太明白,记下来,在这里请教了
第一题
加语句使下面if判断总是真的- if( (*foo = 0) || ((void *)foo == (void *) &foo) ) {
- printf("we have to go through this line");
- }
- 修改
- 加:add missing code, 不改变if语句
-
复制代码 第二题,程序填空
(___为需要填空的地方), 愚笨,不知道下段程序到底是要干什么- struct TreeNode {
- struct TreeNode *left;
- struct TreeNode *right;
- int val;
- };
- struct Stack {
- struct TreeNode *node;
- int flags;
- };
- #define MAX_STACK 100
- void Process(struct TreeNode *Root)
- {
- struct Stack Stack[MAX_STACK];
- struct TreeNode *Cur = Root;
- int top = 0;
- while(cur || top > 0) {
- if(cur) {
- Stack[top].node = cur;
- Stack[top++].flags = 0;
- cur = cur->left;
- } else if( ___ ){
- cur = Stack[--top].node;
- PrintNode(cur);
- ____
- } else {
- cur = Stack[top - 1].node;
- Stack[top - 1].flags = 1;
- ____
- }
- }
- }
复制代码 |
|