| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2056 人关注过本帖
标题:[讨论][转载][讨论]某外企C语言面试题,看你能答对几道!
只看楼主 加入收藏
编程女孩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-6-12
收藏
得分:0 
Question Setup:
-------------------
int a=1;
int b=2;
int c=3;

int *p;
int *q;

c=*p;
p=q;
--------------------
Q3:what are the values of *p and *q and c?
A3:
*p =2; *q =2; c =1;
--------------------
Question setup:
--------------------
int *p;
int *q;
*p=12;
q=p;
--------------------
Q4:what is value of q?
A4:
程序会报错
--------------------

2006-06-13 17:33
编程女孩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-6-12
收藏
得分:0 
Question Setup:
--------------------
void foo()
{
int a=1;
int b=2;
bar(a);
bar(b);
}
void bar(int p)
{
int q;
q=p+2;
}
--------------------
Q5:what are values of integers a and b end of foo()?
A5:
a 还是1 ;b 还是2
--------------------
Q6:Modify the above functions,using pointers,so values at the end of
foo() are a=3 and b=4
A6:
这个是正确的
-----------------------

2006-06-13 17:40
编程女孩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-6-12
收藏
得分:0 
LINKED LIST BASICS
Q7:what is an example of a structure and pointer to that structure?
A7:
struct Student
{
int ID;
char* Name;
bool Sex;
int Age;
};

Student *pStu;
------------------------
Q8:use the struct pointer created above to assign a member of the structure
the value 5?
A8:
pStu->Age =5;
---------------------
Q9:allocate a structure to be used in a single data integer linked list
A9:

list<int> Next_node;
--------------------
Q10:Use the linked list data structure above to create a function that
builds a list of {1,2,3} and returns pointer to beginning of list.
A10:

Next_node->push_frond(1);
Next_node->push_frond(2);
Next_node->push_frond(3);
Next_node->frond();
--------------------
Q11:Write a function to count number of elements in the list
A11:
list<int>::iterator item;
int Count =0;
for(item=Next_node.begin();item!=Next_node.end();item++)
Count++;
--------------------

2006-06-13 17:50
编程女孩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-6-12
收藏
得分:0 
ADVANCED LINKED LIST EXAMPLE
Q12:Use the code snippet below.what do you call this type of function?Summariz
e
the basic operation using assumptions about the data structure.
---------------------------------------------------------------------
struct FileEntry
{
int m_iDecoder;
struct FileEntry *m_pNext;
struct FileEntry *m_pContents;
struct FileEntry *m_pContainer;
int m_iFCBEntry;
};

RETCODE_reentrant FooBar(struct FileEntry *pEntry)
{
RETCODE rtn=!SUCCESS;

if(g_iTotalTracks<MAX_FILES&&pEntry->m_iDector!=FILE_ENTRY_UNUSED)
{
if(pEntry->m_iDector==FILE_ENTRY_DIR)
{
struct FileEntry *pCurrentEntry=pEntry->m_pContents;
while(pCurrentEntry)
{
FooBar(pCurrentEntry);
pCurrentEntry=pCurrentEntry->m_pNext;
}
}
else
{
g_PlayList[g_iTotalTracks]=pEntry;
g_iTotalTracks++;
}
}
rtn=SUCESS;

}
return rtn;
}
定义一个结构体FileEntry
它有两个数据域
三个指针域
又定义一个函数FooBar
它的返回值类型为RETCODE_reentrant
它的作用向结构体插入一个节点
---------------------------------------------------------

THE END

2006-06-13 17:59
mondear
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-6-13
收藏
得分:0 
To:编程女孩

Q6:Modify the above functions,using pointers,so values at the end of
foo() are a=3 and b=4
A6:
这个是正确的



我觉得你对题目的意思理解有误,不是让你判断对错,
它意思是让你修改程序,用上指针,且运行foo()后 a=3 and b=4



2006-06-13 18:03
编程女孩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-6-12
收藏
得分:0 
***用指针来实现***
void foo()
{
int aa =1,bb =2;
int *a;
int *b;
a =&aa;
b =&bb;
bar(a);
bar(b);
}
void bar(int *p)
{
*p+=2;
}

&&&用引用来实现&&&
void foo()
{
int a =1,b =2;
bar(a);
bar(b);
}
void bar(int &p)
{
p+=2;
}

2006-06-13 18:24
mondear
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-6-13
收藏
得分:0 
To:编程女孩
第三题答错了吧?
九到十一要求用纯C写的
十二题没答到点子上(
what do you call this type of function?
2006-06-14 09:00
maymay
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-6-14
收藏
得分:0 
最后一题好像是递归生成树,不知对不对?有没有高手给分析一下?
2006-06-14 09:32
lxgaaa
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-5-17
收藏
得分:0 
不错

天高任鸟飞,海阔任鱼翱
2006-06-14 13:08
trivycool
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-6-10
收藏
得分:0 
struct FileEntry
{
int m_iDecoder;
struct FileEntry *m_pNext;
struct FileEntry *m_pContents;
struct FileEntry *m_pContainer;
int m_iFCBEntry;
};

RETCODE_reentrant FooBar(struct FileEntry *pEntry)
{
RETCODE rtn=!SUCCESS;

if(g_iTotalTracks<MAX_FILES&&pEntry->m_iDector!=FILE_ENTRY_UNUSED)
{
if(pEntry->m_iDector==FILE_ENTRY_DIR)
{
struct FileEntry *pCurrentEntry=pEntry->m_pContents;
while(pCurrentEntry)
{
FooBar(pCurrentEntry);
pCurrentEntry=pCurrentEntry->m_pNext;
}
}
else
{
g_PlayList[g_iTotalTracks]=pEntry;
g_iTotalTracks++;
}
}
rtn=SUCESS;

}
return rtn;
}
---------------------------------------------------------

THE END
定义一个结构体FileEntry
它有两个数据域(m_iDecoder)( m_iFCBEntry)
三个指针域(FileEntry *m_pNext;)(FileEntry *m_pContents;)(FileEntry *m_pContainer;)这些是文件指针
又定义一个函数FooBar
它的返回值类型为RETCODE_reentrant
它的作用向结构体插入一个节点  
这好象不是单纯的C 
2006-06-14 22:02
快速回复:[讨论][转载][讨论]某外企C语言面试题,看你能答对几道!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018022 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved