广州一家公司的笔试题C++

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 145 收藏 0 点赞 0 评论 0

一、    问答
1、实模式与保护模式。为什么要设计这两种模式?好处在什么地方?分别写出各自寻址的
过程。

2、请阅读以下一段程序,并给出答案。
class A
{
public:
A(){ doSth() }
virtual void doSth(){ printf(“I am A”);}
}

class B:public A
{
public:

virtual void doSth(){ printf(“I am B”);}
}

B b;
执行结果是什么?为什么?

3、在STL的应用中 map<int,int>这种key-value的应用很多,如果key的类型是GUID,该如
何处理?

4、一个内存变量a=5,有5个线程需要对其进行操作,其中3个对a进行加1操作,2个对a进
行减1操作,为了保证能够得到正常结果6,需要使用什么方法?(列出越多越好)

5、描述并比较以下对象:事件,信标,临界区,互斥对象。

6、cdecl、stdcall、fastcall是什么?哪种可以实现个数不定的入口参数,为什么?

二、    程序设计(以下题目请写出实现代码)
1、有一段文本,统计其中的单词数。例如:
As a technology , “HailStorm” is so new that it is still only known by its

code name.
注意:单词间的间隔不一定是一个空格

2、国际象棋有8×8格,每个格子可放一个棋子。皇后的规则是可以横、竖、斜移动。在一
个棋盘放置8个皇后,并使它们互相无法威胁到彼此。

3、输入二个64位的十进制数,计算相乘之后的乘积
已知strcpy函数的原型是:
char * strcpy(char * strDest,const char * strSrc);
1.不调用库函数,实现strcpy函数。
2.解释为什么要返回char *。


1. How do you code an infinite loop in C?

2. Volatile:

a) What does the keyword volatile mean? Give an example

b) Can a parameter be both const and volatile? Give an example

c) Can a pointer be volatile? Give an example

3. What are the values of a, b, and c after the following instructions:

int a=5, b=7, c;

c = a+++b;

4, What do the following declarations mean?

a) const int a;

b) int const a;

c) const int *a;

d) int * const a;

e) int const * a const;

5. Which of the following statements describe the use of the keyword

static?

a) Within the body of a function: A static variable maintains its value

between function revocations

b) Within a module: A static variable is accessible by all functions

within that module

c) Within a module: A static function can only be called by other

functions within that module

6. Embedded systems always require the user to manipulate bits in

registers or variables. Given an integer variable a, write two code fragments.

The first should set bit 5 of a. The second shnuld clear bit 5 of a. In both

cases, the remaining bits should be unmodified.

7. What does the following function return?

char foo(void)

{

unsigned int a = 6;

iht b = -20;

char c;

(a+b > 6) ? (c=1): (c=0);

return c;

}

8. What values are printed when the following C program is executed?

int i = 8;

void main(void)

(

9. What will be the output of the following C code?

main()

{

int k, num= 30;

k =(num > 5 ? (num <=10 ? 100:200): 500);

printf(“%d”, k);

}

10. What will the following C code do?

int *ptr;

ptr =(int *)Ox67a9;

*ptr = Oxaa55;

11. What will be the output of the follow C code?

#define product(x) (x*x)

main()

{

int i = 3, j, k;

j = product(i++);

k = product(++i);

printf(“%d %d”,j,k);

}

12. Simplify the following Boolean expression

!((i ==12) || (j > 15))
struct Node {
int value;
Node* next;
};
1.1 Get the value of the Nth node from last node in the linked list.

PARAM HEAD: the first element in the linked list:
PARAM n: the number of the node counted reversely
RETURN: the value of the node, or -1 if not exists

int GetValue(Node* HEAD, int n)
{
}

1.2 Delete a node WITHOUT using the HEAD pointer.
PARAM p: A pointer pointed to a node in the middle of the linked list.
RETURN: void

void Delete(Node* p)
{
}

1.3 Insert a new node before p WITHOUT using the HEAD pointer
PARAM p: A pointer pointed to a node in the middle of the linked list.
PARAM value: new Node value
RETURN: void

void Insert(Node* p, int value)
{
}

Question 2:

Please write a String class with following features:
四:
1. Default constructors with no parameters passed.
2. Constructor with parameter const char* sourceString passed.
3. Destructor.
4. Copy constructor.
5. Assignment operator.
6. Operator overloading operator+= which appends another String instance into current String instance.
7. A method returning length of the String.
8. A conversion operator which converts the current String instance into raw C-style string of type const char*.


1. Part of the signature of the String class is:
class String {
….
};

Other part of signature and implementation is completed by you.

2. Please make the implementation as simple as possible. Only help functions and classes from standard C&C++ may be used to aid your implementation.

3. If possible please suggest further improvement of the String class.

Question 3:

Given a link list, detect whether it’s circular using only one loop.

Tips: Below implementation is allowed
for( … )
{

}

The following implementations is NOT allowed

for( … )
{

for( … ) {…}
}

or

for( p = list->head, q = list->head; p != NULL && q != NULL; p = p->next )
{

}

for( … )
{

}

(1)

int Calc(unsigned int x)
{
int count=0;
while(x)
{
printf(“x=%in”,x);
count++;
x=x&(x-1);
}

return count;

}
问Calc(9999)的值是多少。

(2)检查错误

int CopyStringCount(const char* Str)
{
int nCount = 0;
char* pBuffer;

pBuffer = new char[_MAX_PATH];

strcpy(pBuffer,Str);

for(;*pBuffer!=’’; pBuffer++)
if(*pBuffer == ”) nCount ++;

// delete [] pBuffer;

return nCount;
}

(3)写出结果

void foo(int p1[])
{
*p1 += 5;
}

void bar(int p2[])
{
p2[1] = 15;
}

void main()
{
int a[]={3,4,5};
int b[]={3,4,5};
int *p2;
p2=&a[1];
bar(p2);
printf(“%i %i %in”,a[0],a[1],a[2]);
p2=&b[0];
p2++;
foo(p2);
bar(p2);
printf(“%i %i %in”,b[0],b[1],b[2]);
}

(4)

有一5节车厢的过山车,每节能座两人,现有Luair,Jack,Gwen,Tom,Mark,Paul,6人去乘
车,有以下条件
1,Luair和别人同乘
2,Mark 不合别人同乘,而且Mark的前一节车厢是空的
3,Tom 不和Gwen 与 Paul 中的任何一人同乘
4,Gwen乘3,或者4节

—————————————————————————–
————-


1写出下列算法的时间复杂度。
(1)冒泡排序;
(2)选择排序;
(3)插入排序;
(4)快速排序;
(5)堆排序;
(6)归并排序;

2写出下列程序在X86上的运行结果。

struct mybitfields
{
unsigned short a : 4;
unsigned short b : 5;
unsigned short c : 7;
}test

void main(void)
{
int i;
test.a=2;
test.b=3;
test.c=0;

i=*((short *)&test);
printf(“%dn”,i);
}

3写出下列程序的运行结果。

unsigned int i=3;
cout<
4写出下列程序所有可能的运行结果。

int a;
int b;
int c;

void F1()
{
b=a*2;
a=b;
}

void F2()
{
c=a+1;
a=c;
}

main()
{
a=5;
//Start F1,F2 in parallel
F1(); F2();
printf(“a=%dn”,a);
}

5考察了一个CharPrev()函数的作用。

6对 16 Bits colors的处理,要求:
(1)Byte转换为RGB时,保留高5、6bits;
(2)RGB转换为Byte时,第2、3位置零。

7一个链表的操作,注意代码的健壮和安全性。要求:
(1)增加一个元素;
(2)获得头元素;
(3)弹出头元素(获得值并删除)。

8一个给定的数值由左边开始升位到右边第N位,如
0010<<1 == 0100
或者
0001 0011<<4 == 0011 0000
请用C或者C++或者其他X86上能运行的程序实现。
—————————————————————————–
———————————–
附加题(只有在完成以上题目后,才获准回答)
In C++, what does “explicit” mean? what does “protected” mean?

explicit
C++ Specific

This keyword is a declaration specifier that can only be applied to
in-class constructor declarations. Constructors declared explicit will not
be considered for implicit conversions. For example:

class X {
public:
explicit X(int); //legal
explicit X(double) { //legal // … }
};
explicit X::X(int) {} //illegal
An explicit constructor cannot take part in implicit conversions. It can
only be used to explicitly construct an object. For example, with the class
declared above:

void f(X) {}
void g(int I)
{
f(i); // will cause error
}
void h()
{
X x1(1); // legal
}
The function call f(i) fails because there is no available implicit
conversion from int to X.

Note It is meaningless to apply explicit to constructors with multiple
arguments, since such constructors cannot take part in implicit conversions.

END C++ Specific

protected
C++ Specific —>

protected: [member-list]

protected base-class

When preceding a list of class members, the protected keyword specifies
that those members are accessible only from member functions and friends of
the class and its derived classes. This applies to all members declared up
to the next access specifier or the end of the class.

When preceding the name of a base class, the protected keyword specifies
that the public and protected members of the base class are protected
members of the derived class.

Default access of members in a class is private. Default access of members
in a structure or union is public.

Default access of a base class is private for classes and public for
structures. Unions cannot have base classes.

For related information, see public, private, friend, and Table of Member
Access Privileges.

END C++ Specific

Example

// Example of the protected keyword
class BaseClass {
protected: int protectFunc();
};
class DerivedClass : public BaseClass
{ public:
int useProtect() { protectFunc(); } // protectFunc accessible from
derived class
};
void main()
{
BaseClass aBase;
DerivedClass aDerived;
aBase.protectFunc(); // Error: protectFunc not accessible
aDerived.protectFunc(); // Error: protectFunc not accessible in derived
class
}

How do you code an infinite loop in C?
2. Volatile:
a) What does the keyword volatile mean? Give an example
b) Can a parameter be both const and volatile? Give an example
c) Can a pointer be volatile? Give an example
3. What are the values of a, b, and c after the following instructions:
int a=5, b=7, c;
c = a+++b;
4, What do the following declarations mean?
a) const int a;
b) int const a;
c) const int *a;
d) int * const a;
e) int const * a const;
5. Which of the following statements describe the use of the keyword
static?
a) Within the body of a function: A static variable maintains its value
between function revocations
b) Within a module: A static variable is accessible by all functions
within that module
c) Within a module: A static function can only be called by other
functions within that module
6. Embedded systems always require the user to manipulate bits in
registers or variables. Given an integer variable a, write two code
fragments.

The first should set bit 5 of a. The second shnuld clear bit 5 of a. In
both

cases, the remaining bits should be unmodified.
7. What does the following function return?
char foo(void)
{
unsigned int a = 6;
iht b = -20;
char c;
(a+b > 6) ? (c=1): (c=0);
return c;
}
8. What values are printed when the following C program is executed?
int i = 8;
void main(void)
(

9. What will be the output of the following C code?
main()
{
int k, num= 30;
k =(num > 5 ? (num <=10 ? 100:200): 500);
printf(“%d”, k);
}
10. What will the following C code do?
int *ptr;
ptr =(int *)Ox67a9;
*ptr = Oxaa55;
11. What will be the output of the follow C code?
#define product(x) (x*x)
main()
{
int i = 3, j, k;
j = product(i++);
k = product(++i);
printf(“%d %d”,j,k);
}
12. Simplify the following Boolean expression
!((i ==12) || (j > 15))
13. How many flip-flop circuits are needed to divide by 16?
14. Provides 3 properties that make an OS, a RTOS?
15. What is pre-emption?
16. Assume the BC register value is 8538H, and the DE register
value is 62A5H.Find the value of register BC after the following
assembly operations:
MOV A,C
SUB E
MOV C,A
MOV A,B
SBB D
MOV B,A
17.In the Assembly code shown below
LOOP: MVI C,78H
DCR C
JNZ LOOP
HLT
How many times is the DCR C Operation executed?

18.Describe the most efficient way(in term of execution time
and code size) to divide a number by 4 in assembly language

19.what value is stored in m in the following assembly language code
fragment if n=7?
LDAA #n
LABEL1: CMPA #5
BHI L3
BEQ L2
DECA
BRA L1
LABEL2: CLRA
LABEL3: STAA #m
20. What is the state of a process if a resource is not
available?
#define a 365*24*60*60
21. Using the #define statement, how would you
declare a manifest constant that returns the
number of seconds in a year? Disregard leap
years in your answer.
22. Interrupts are an important part of embedded
systems. Consequently, many compiler vendors
offer an extension to standard C to support interrupts.
Typically, the keyword is __interrupt. The following
code uses __interrupt to define an interrupt service
routine (ISR). Point out problems in the code.

__interrupt double compute_area (double radius)
{
double area = PI * radius * radius;
printf(“nArea = %f”, area);
return area;
}


1.一株查找二叉树,其结点A、B、C、D、E、F依次存放在一个起始地址为n(假定地址以字

为单位顺序编号)的连续区域中,每个节点占4个字节:前两个字节存放结点值,后两个字节

次放左指针、右指针.
若该查找二叉树的根结点为E,则它的一种可能的前序遍历为____ ,相应的层次遍历为___
_
.
在以上两种遍历情况下,结点C的左指针LC的存放地址为_____ ,LC的内容为______ 结点A

左指针RA的内容为_______.
供选择的答案
(1) A. EAFCBD B.EFACDB C.EABCFD D.EACBDF
(2) A. EAFCBD B.EFACDB C.EABCFD D.EACBDF
(3) A.n+4 B.n+10 C.n+12 D.n+13
(4) A.n+9 B.n+8 C.n+12 D.n+13
(5) A.n+4 B.n+8 C.n+12 D.n+16

2.虚存页面调整算法有多种,______ 调度算法不是页面调度算法.
供选择的答案
A.后进先出 B.先进先出 C.最近最少使用 D.随机选择

3.在软件开发过程中常用图作为描述工具.如DFD就是面向_______分析方法的描述工具.

一套分层DFD中,如果某一张图中有N个加工(Process),则这张图允许有_____ 张子图.在

张DFD图中,任意两个加工之间_____ .在画分层DFD时,应保持_____ 之间的平衡.DFD中从

统的输出流到系统的输出流的一连串连续变换形成一种信息流,这种信息可分为_____两

.
A.(1)数据结构 (2)数据流 (3)对象 (4)构件
B.(1)0 (2)1 (3)1-N (4)0-N
C.(1)有且仅有一条数据流
(2)至少有一条数据流
(3)可以有0条或多条名字互不相同的数据流
(4)可以有0或多条数据流,但允许其中存若干条名字相同的数据流.
D.(1)父图与其子图 (2)同一父图的所有子图 (3)不同父图的所有子图 (4)同一子图的
所有直接父图.
E.(1)控制流和变换流
(2)变换流和事务流
(3)事务流和事件流
(4)事件流和控制流

4.用二进制加法器对二一十进制编码的十进制数求和,当和的本位十进制数二一十进制编

小于等于1001且向高位无进位时,_____ ;当和小于等于1001且向高位存进位时,_____;当

大于1001时,_____
(1)-(3) A:不需进行修改
B:需进行加6修改
C:需进行减6修改
D:进行加6或减6修改,需进一步判别.

5.www页面访问的大致过程如下:
用户在浏览器中输入要访问的WWW页面的____地址(http://hostname/directory/file)

览器通过____ 查询上述输入信息所指的WEB服务器的IP地址;浏览器通过网络与该IP地址

的WEB服务器的______服务端之间建立一条______连接;浏览器依照相关协议发送_____命

;WEB服务器根据命令取出文档,发送回来;浏览器释放连接,显示该文档.
(1) A.URL B.EMS C.NDS D.DNS
(2)A.NAT B.EMS C.NDS D.DNS
(3)A.HTML B.HTTP C.SMTP D.SNMP
(4)A.RTP B.IP C.TCP D.UDP
(5)A.TCP B.GET C.UDP D.PUT

6.假设某计算机具有1MB的内存(目前使用的计算机往往具有64MB以上内存),并按字节编

,为了能存取该内存各地址的内容,其地址寄存器至少需要二进制____位.为使4字节组成

字段从存储器中一次读出,要求存放存储器中的字边界对齐,一个字节的地址码应_____若

储器周期为200ns,且每个周期可访问4个字节,则该存储器带宽为_____bit/s假如程序员

用的地址为______,而真正访问内存的地址称为_______
A.(1)10 (2)16 (3) 20 (4)32
B.(1)最低两位00 (2)最低两位为10 (3)最高两位为00 (4)最高两位为10
C.(1)20M (2)40M (3)80M (4)160M
D.(1)有效地址 (2)程序地址 (3)逻辑地址 (4)物理地址
E.(1)指令地址 (2)物理地址 (3)内存地址 (4)数据地址

7.英语题
Soon,more of the information we receive via the internet could come _____in
di
gital wrappers.
Wrappers are made up ______ softwore code that’s targeted to do specific
thin
gs with the data _____within them such as helping to define queries for
search
engines They also keep _____from_____access to that code.
(1) A.Package B.packaged C.packages D.packaging
(2)A.of B.off C.on D.out
(3)A.close B.closed C.enclose D.enclosed
(4)A.insiders B.money C.outsiders D.warehouse
(5)A.gain B.gained C.gains D.gaining

二.设计题
1.在VC中怎样获得父窗口的指针(写出代码)
2.怎样创建一个临时文件
3.怎样获得状态栏和工具栏的指针.
4.访问控件存几种方法

三.填空题:
1.ODBC的数据类型分为_________和_________
2.VC访问数据库的方式____________________
3.VC的线路分为_________和_________,它是用什么对象表示的_________
4.下列中a的值是_________
#define AAA 200
#define BBB AAA+100
int a= BBB*2

试题一:基础知识
1、从供选择的答案中,选出应填入下面叙述中_?_内的最确切的解答,把相应编号写在

卷的对应栏内。
假设某计算机具有1M 字节的内存(目前使用的计算机往往具有64M字节以上的内存),

按字节编址,为了能存取该内存各地址的内容,其地址寄存器至少需要二进制_A_位。为
使
4字节组成的字能从存储器中一次读出,要求存放在存储器中的字边界对齐,一个字的地

码应_B_。若存储周期为200NS,且每个周期可访问4个字节,则该存储器带宽为_C_BIT/S

假如程序员可用的存储空间为4M字节,则程序员所用的地址为_D_,而真正访问内存的地

称为_E_。
供选择的答案:
A: ①10 ②16 ③20 ④32
B: ①最低两位为00 ②最低两位为10 ③最高两位为00 ④最高两位为10
C: ①20M ②40M ③80M ④160M
D: ①有效地址 ②程序地址 ③逻辑地址 ④物理地址
E: ①指令 ②物理地址 ③内存地址 ④数据地址

2、从供选择的答案中。选出应填入下面叙述中_?_内的最确切的解答,把相应编号写

答卷的对应栏内。
给定结点的关键字序列(F、B、J、G、E、A、I、D、C、H),对它按字母的

典顺序进行排列,采用不同方法,其最终结果相同。但中间结果是不同的。
Shell排序的第一趟扫描(步长为5)结果应为_A_。
冒泡排序(大数下沉)的第一趟起泡的效果是_B_3.
快速排序的第一趟结果是_C_。
二路归并排序的第一趟结局是 _D_。
供选择的答案
A:①(B、F、G、J、A、D、I、E、H、C)
②(B、F、G、J、A、E、D、I、C、H)
③(A、B、D、C、E、F、I、J、G、H)
④(C、B、D、A、E、F、I、G、J、H)
B:①(A、B、D、C、F、E、I、J、H、G)
②(A、B、D、C、E、F、I、H、G、J)
③(B、F、G、E、A、I、D、C、H、J)
④(B、F、G、J、A、E、D、I、C、H)
C:①(C、B、D、A、F、E、I、J、G、H)
②(C、B、D、A、E、F、I、G、J、H)
③(B、A、D、E、F、G、I、J、H、C)
④(B、C、D、A、E、F、I、J、G、H)
D:①(B、F、G、J、A、E、D、I、G、H)
②(B、A、D、E、F、G、I、J、H、C)
③(A、B、D、C、E、F、I、J、G、H)
④(A、B、D、C、F、E、J、I、H、C)

3、从供选择的答案中,选出应填入下面叙述中_?_内的最确切的解答.把相应编号写

答卷的对应栏内。
进程是操作系统中的一个重要概念。进程是一个具有一定独立功能的程序在某个数据集

上的一次_A2_。
进程是一个_B3_的概念,而程序是一个_C3_的概念。
进程的最基本状态有_D4_。在一个单处理机中,若有6个用户进程,在非管态的某一时

,处于就绪状态的用户进程最多有_E5_个。
供选择的答案
A:①单独操作 ②关联操作 ③运行活动 ④并发活动
B:①静态 ②动态 ③逻辑 ④物理
C:①物理 ②逻辑 ③动态 ④静态
D:①就绪、运行、隐蔽 ②停止、就绪、运行
③运行、就绪、阻塞 ④就绪、撤消、运行
E:①5 ②6 ③1 ④4

4、软件设计中划分模块的一个准则是_A2_。两个模块之间的耦合方式中,_B3_耦

的耦合度最高,_C4_耦合的耦合度最低。一个模块内部的内聚种类中_D4_内聚的

聚度最高,_E1_内聚的内聚度最低。
供选择的答案
A:①低内聚低耦合②低内聚高耦合③高内聚低耦合④高内聚高耦合
B:①数据 ②非直接 ③控制 ④内容
C:①数据 ②非直接 ③控制 ④内容
D:①偶然 ②逻辑 ③功能 ④过程
E:①偶然 ②逻辑 ③功能 ④过程

5、从供选择的答案中选出应填入下面叙述中_?_内的最确切的解答,把相应编号写在

卷的对应栏内。
最常用的一种基本数据模型是关系数据模型,它用统一的_A 1_结构来表示实体及实体

间的联系。关系数据库的数据操作语言(DML)主要包括_B2_两类操作。
关系运算以关系代数为理论基础,关系代数的最基本操作是并、差、笛卡尔积、_C4_

用R∣×∣S 表示关系 R和关系 S的_D1_。
设关系R和关系S图示如下:
R: A B C S: B C D T: A B C D
则关系T是关系R和关系S_E _的结果。
供选择的答案
A:①树 ②网络 ③图 ④二维表
B:①插入和删除 ②检索和更新 ③查询和编辑 ④统计和修改
C:①投影、联接 ②联接、选择 ③选择、投影 ④交、选择
D:①联接 ②笛卡尔积 ③日联接 ④自然联接
E:①自然联接 ②θ联接 ③笛卡尔积 ④并

试题二:程序设计
1、用你所熟悉的任意一种程序语言,编写一个完整的过程,将一个字符串插入到另一个

符串的某个位置后面(例如:将“abc”插入到“abcdef”的第三个字符位置后面,结果

“abcabcdef”)。编写程序时,请在必要的地方加以注释(注:不能用该程序语言的内

函数或过程)。

2、用你所熟悉的任意一种程序语言,编写一个完整的过程,完成从一个给定的完整的文

路径(如“C:My DocumentsSoftware Test 1.00.doc”)中,析取文件名,扩展名和文

所处目录的功能,编写程序时,请在必要的地方加以注释(注:不能用该程序语言的内置

数或过程)。


编写类String 的构造函数,析构函数和赋值函数
已知类String 的原型为
class string
{
public:
string(const char *str=null);//普通构造函数
string(const string &other);//拷贝构造函数
—string(void);
string &operate=(const string &other);//赋值函数
private:
char * m-data;//用于保存字符串
};
请编写string 的上述4个函数
三. 有关内存的思考题
1. void getmemory(char *p)
{ p=(char*)mallol(100);
}
void test(void)
{
char * str =null;
getmemory(str);
strcpy(str,”hello,world”);
printf(str);
}
请问运行Test函数会有什么样的结果
2. char*getmemory(void)
{ char p[]=”hello world”;
return p;
}
void test(void)
{
char *str=null;
str=Getmemory();
printf(str);
} 请问运行Test 函数会有什么样的结果.


C++/C试题
本试题仅用于考查C++/C程序员的基本编程技能。内容限于C++/C常用语法,不涉及数据

构、算法以及深奥的语法。考试成绩能反映出考生的编程质量以及对C++/C的理解程度,

不能反映考生的智力和软件开发能力。
笔试时间90分钟。请考生认真答题,切勿轻视。

一、请填写BOOL , float, 指针变量 与“零值”比较的 if 语句。(10分)
提示:这里“零值”可以是0, 0.0 , FALSE或者“空指针”。例如 int 变量 n 与“零

”比较的 if 语句为:
if ( n == 0 )
if ( n != 0 )
以此类推。

请写出 BOOL flag 与“零值”比较的 if 语句:
请写出 float x 与“零值”比较的 if 语句:
请写出 char *p 与“零值”比较的 if 语句:

二、以下为Windows NT下的32位C++程序,请计算sizeof的值(10分)

char str[] = “Hello” ; char *p = str ;int n = 10;请计算sizeof (str )
= sizeof ( p ) = sizeof ( n ) = void Func (
char str[100]){请计算 sizeof( str ) = }
void *p = malloc( 100 );请计算sizeof ( p ) =

三、简答题(25分)

1、头文件中的 ifndef/define/endif 干什么用?

2、#include 和 #include “filename.h” 有什么区别?

3、const 有什么用途?(请至少说明两种)

4、在C++ 程序中调用被 C编译器编译后的函数,为什么要加 extern “C”声明?

5、请简述以下两个for循环的优缺点

// 第一个for (i=0; i ing();} // 第二个if (condition){for (i=0; i for (i=0;
i 优点:缺点: 优点:缺点:

四、有关内存的思考题(20分)

void GetMemory(char *p){p = (char *)malloc(100);}void Test(void) {char *str
=
NULL;GetMemory(str); strcpy(str, “hello world”);printf(str);}请问运行Test函数

有什么样的结果?答: char *GetMemory(void){ char p[] = “hello world”;return
p;
}void Test(void){char *str = NULL;str = GetMemory(); printf(str);}请问运行Tes
t
函数会有什么样的结果?答:
Void GetMemory2(char **p, int num){*p = (char *)malloc(num);}void
Test(void){c
har *str = NULL;GetMemory(&str, 100);strcpy(str, “hello”); printf(str); }请问

行Test函数会有什么样的结果?答: void Test(void){char *str = (char *)
malloc(1
00); strcpy(str, “hello”); free(str); if(str != NULL) { strcpy(str, “
world”); printf(str);}}请问运行Test函数会有什么样的结果?答:

五、编写strcpy函数(10分)
已知strcpy函数的原型是
char *strcpy(char *strDest, const char *strSrc);
其中strDest是目的字符串,strSrc是源字符串。

(1)不调用C++/C的字符串库函数,请编写函数 strcpy

(2)strcpy能把strSrc的内容复制到strDest,为什么还要char * 类型的返回值?

六、编写类String的构造函数、析构函数和赋值函数(25分)
已知类String的原型为:
class String
{
public:
String(const char *str = NULL); // 普通构造函数
String(const String &other); // 拷贝构造函数
~ String(void); // 析构函数
String & operate =(const String &other); // 赋值函数
private:
char *m_data; // 用于保存字符串
};
请编写String的上述4个函数。

盛大游戏策划笔试题目!

1.游戏策划的关键词
2.游戏运营与研发之间的关系
3.设计策划案目录一个
4.新的赢利方式《除点卡和出卖游戏物品两种之外》
5.游戏人群的特征—白领。女人。小孩。骨灰级玩家
6.1)给一个旧魔法,设计一个新魔法(具体不说了)
2)给《坦克大战》设计一个开房间类的策划方案
3)地图的不平衡,造成法师升级速度快,策划设计一个新地图,使战士的升级速度加
快!
十一
一. int a[2][3]={1,2,3,4,5};
问:a[1][2]=?
二。char *p=”hello”;
printf(“%s”,p);
p++;
printf(“%s”,p);
printf(“%c”,*p);

十二
1.进程和线程的差别。

2.Heap与stack的差别。

3.Windows下的内存是如何管理的?

4.介绍.Net和.Net的安全性。

5.客户端如何访问.Net组件实现Web Service?

6.C/C++编译器中虚表是如何完成的?

7.谈谈COM的线程模型。然后讨论进程内/外组件的差别。

8.谈谈IA32下的分页机制。

9.给两个变量,如何找出一个带环单链表中是什么地方出现环的?

10.在IA32中一共有多少种办法从用户态跳到内核态?

11.如果只想让程序有一个实例运行,不能运行两个。像winamp一样,只能开一个窗口
,怎样实现?

12.如何截取键盘的响应,让所有的‘a’变成‘b’?

13.Apartment在COM中有什么用?为什么要引入?

14.存储过程是什么?有什么用?有什么优点?

15.Template有什么特点?什么时候用?

16.谈谈Windows DNA结构的特点和优点
十三
1.1000!有几位数,为什么?

2.F(n)=1 n>8 n<12

F(n)=2 n<2

F(n)=3 n=6

F(n)=4 n=other

使用+ – * /和sign(n)函数组合出F(n)函数

sign(n)=0 n=0

sign(n)=-1 n<0

sign(n)=1 n>0

3.编一个程序求质数的和,例如F(7)=1+3+5+7+11+13 +17=57。

评论列表
文章目录