Work 版 (精华区)
发信人: bruceleeljh (brucelee), 信区: Work
标 题: 矽玛特笔试题software部分
发信站: BBS 哈工大紫丁香站 (Wed Nov 2 16:43:39 2005)
Basic Pointers
Question Setup:
-------------------
int a=1;
int b=2;
int c=3;
int *p;
int *q;
-------------------
Q1:
initialize p to point to a
initialize q to point to b
A1:
-------------------
Q2:Using Q1 setup and answer, what is value of *p and *q?
A2:
-------------------
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:
--------------------
Question setup:
--------------------
int *p;
int *q;
*p=12;
q=p;
--------------------
Q4:what is value of q?
A4:
--------------------
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:
--------------------
Q6:Modify the above functions,using pointers,so values at the end of
foo() are a=3 and b=4
A6:
-----------------------
LINKED LIST BASICS
Q7:what is an example of a structure and pointer to that structure?
A7:
------------------------
Q8:use the struct pointer created above to assign a member of the structure
the value 5?
A8:
---------------------
Q9:allocate a structure to be used in a single data integer linked list
A9:
--------------------
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:
--------------------
Q11:Write a function to count number of elements in the list
A11:
--------------------
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; 在这里,题出现了问题!!
}
---------------------------------------------------------
THE END
--
※ 来源:·哈工大紫丁香 http://bbs.hit.edu.cn·[FROM: 202.118.247.137]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.019毫秒