[讨论][转载][讨论]某外企C语言面试题,看你能答对几道!
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
----------------解决方案--------------------------------------------------------
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: p = &a;
q = &b;
-------------------
Q2: Using Q1 setup and answer, what is value of *p and *q?
A2: 1,2
-------------------
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: error in your question !
--------------------
Question setup:
--------------------
int *p;
int *q;
*p=12;
q=p;
--------------------
Q4: what is value of q?
A4: wild pointer p !!!
--------------------
----------------解决方案--------------------------------------------------------
Q5:what are values of integers a and b end of foo()?
A5: a=1 b=2
米想到我上面的和星星一样
----------------解决方案--------------------------------------------------------
大家难道对这样的题目不感兴趣?特别是最后一题!
----------------解决方案--------------------------------------------------------
大家对有语法错误的题目不感兴趣!
例如最后一题,花括弧都不匹配,咋做?
----------------解决方案--------------------------------------------------------
作业就作业,什么外企C语言面试题
----------------解决方案--------------------------------------------------------
考英文的吧
----------------解决方案--------------------------------------------------------
不做不知道,一做吓一跳。
唉,基础太差!基本概念竟要查书,看来能编写代码解决问题,不一定就是学会了。
弄点补品好好补补。。。。
----------------解决方案--------------------------------------------------------
晕倒,要是作业题,有必要搞成英文的么?!!
----------------解决方案--------------------------------------------------------
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:
p =&a; q =&b;
-------------------
Q2:Using Q1 setup and answer, what is value of *p and *q?
A2:
*p =1; *q =2;
-------------------
----------------解决方案--------------------------------------------------------