叠拓测试笔试题
admin
2024-02-18 07:49:12
0

叠拓测试笔试题

下面是为您介绍的关于叠拓测试笔试题,请您对此进行参考:

Instructions
Please answer following questions in English, you can only use less than 60 minutes for this test

1. Preprocessor 10 points)
a) Please define a Macro by using preprocess instruction #define in 16-bit machine, the constant is used to indicate how many seconds in one year. (To ignore the leap year)

#define SEC_PER_YEAR (365*24*60*60UL)
(Note: If you define it to be (365*24*60*60)UL, you maybe find that it does not compile well.)


b) Please define a Macro, which is used to compare two parameters and return the smaller parameter.

#define MIN(a, b) ((a)<=(b)?(a):(b))


2. What is the problem of the below code (5 points)
#include
char* Func( void )
{
char p[10];
strcpy( p, "111" );
return p;
}

This function can not return the string of “111”.

3. Data declarations (10 points)
Please define a variable according to the below requirement, for example
Requirement: An integer
Answer: int a;

a) A pointer to an integer (1 point)
int *a;

b) A pointer to a pointer to an integer (1 point)
int **a;

c) An array of 10 integers (1 point)
int a[10];

d) An array of 10 pointers to integers (1 point)
int *a[10];


e) A pointer to an array of 10 integers (2 points)
int (*a)[10];

f) A pointer to a function that takes an integer as an argument and returns an integer (2 points)
int (*a)(int)

g) An array of ten pointers to functions that take an integer argument and return an integer (2 points)
int (*a[10])(int)

4. What’s the output of the function and why? (6 points)
void foo(void)
{
unsigned int a = 6;
int b = -20;
(a+b > 6) ? puts("> 6") : puts("<= 6");
}

Result:“>6”
Reason: When a variable of integer operates with a variable of unsigned integer, the integer will be automatically converted to unsigned integer, so the “-20” will be converted to be a large unsigned integer.


5. Const (9 points)
In the following codes, there are some “const”, what is meaning of each them?

a) const char *pa;
The content of pa is read-only.

b) char * const pc = &ca;
The address of pc is read-only.


c) const char * const pd =

&cb;
Both the address and content of pd are read-only.

6. Accessing fixed memory locations (10 points)
Please make out a few lines of C codes for accessing a fixed memory location. Requirement is to write an int variable 0xaa55 into the fixed address 0x67a9.

int *p;
p = (int *)0x67a9;
*p = 0xaa55;



7. Typedef (10 points)
Typedef is used to define a new structure which can replace the old structure.
You can also use preprocessor for the same things. But there must be difference between them, so please think of the below code, and answer what is the difference?

#define dPS struct s *
typedef struct s * tPS;


I will declare two object variables for them, such as:
dPS test1, test2;
tPS test3, test4;

You will understand what’s the differences.
1. test1 is a pointer object of struct s, but test2 is not, it is object of struct s.
2. both test3 and test4 are pointer object of struct s.


8. What’s the output of the code? (10 points)
1) #include
using namespace std;

class Base
{
public:
virtual void f(float x){ cout << "Base::f(float) " << x << endl; }
void g(float x){ cout << "Base::g(float) " << x << endl; }
void h(float x){ cout << "Base::h(float) " << x << endl; }
};

class Derived : public Base
{
public:
virtual void f(float x){ cout << "Derived::f(float) " << x << endl; }
void g(int x){ cout << "Derived::g(int) " << x << endl; }
void h(float x){ cout << "Derived::h(float) " << x << endl; }
};

void main(void)
{
Derived d;
Base *pb = &d;
Derived *pd = &d;
pb->f(3.14f);
pd->f(3.14f);
pb->g(3.14f);
pd->g(3.14f);
pb->h(3.14f);
pd->h(3.14f);
}

Result:
Derived::f(float) 3.14
Derived::f(float) 3.14
Base::g(float) 3.14
Derived::g(int) 3.14
Base::h(float) 3.14
Derived::h(float) 3.14

相关内容

热门资讯

315活动方案 315活动方案(精选8篇)  方案是从目的、要求、方式、方法、进度等都部署具体、周密,并有很强可操作...
小学国庆节活动方案 小学国庆节活动方案一、活动目的:为隆重、热烈、活泼的'庆祝中华人民共和国成立59周年,激发少先队员的...
庆五一迎五四活动方案 庆五一迎五四活动方案(通用11篇)  为了确保活动有序有力开展,常常需要预先准备活动方案,活动方案其...
徒步活动方案 徒步活动方案  为了确保工作或事情有序地进行,常常需要提前进行细致的方案准备工作,方案具有可操作性和...
“让读书成为好习惯”主题读书... “让读书成为好习惯”主题读书月活动方案(通用11篇)  为有力保证事情或工作开展的水平质量,通常需要...
旅游项目策划方案 旅游项目策划方案范文(通用8篇)  为了确保事情或工作得以顺利进行,就常常需要事先准备方案,方案是解...
白露文案 白露文案(精选130句)  随着社交网络的迅猛发展,大家都听说过或者使用过一些比较经典的文案吧,文案...
宪法宣传活动方案 宪法宣传活动方案  什么是活动方案?  活动方案指的是为某一次活动所指定的书面计划,具体行动实施办法...
圣诞节目策划方案 圣诞节目策划方案  为确保事情或工作顺利开展,往往需要预先进行方案制定工作,方案是为某一行动所制定的...
芒种节气文案 芒种节气文案(精选70句)  随着社交网络的发展,越来越多人钟情于在网上发布文案,文案用于记录和分享...
虎年四字文案 虎年四字文案  随着社交网络的`普遍使用,说到文案,大家肯定都不陌生吧,文案用以展现自己对生活的热爱...
汽车产品营销活动策划方案 汽车产品营销活动策划方案(通用10篇)  为了确保工作或事情能有条不紊地开展,常常需要提前进行细致的...
庆祝教师节活动流程方案 庆祝教师节活动流程方案  为了确保我们的努力取得实效,往往需要预先进行方案制定工作,方案是阐明具体行...
新公司组建团队方案 新公司组建团队方案通用  为了确保事情或工作有序有效开展,就常常需要事先准备方案,方案是从目的、要求...
九九重阳敬老文案 九九重阳敬老文案  在平平淡淡的学习、工作、生活中,大家都有令自己印象深刻的文案吧,文案用以分享自己...
春游活动的策划方案 春游活动的策划方案(精选8篇)  为了确保活动安全顺利进行,时常需要预先制定一份周密的活动方案,活动...
中秋节创意文案短句 中秋节创意文案短句  随着社交网络和信息技术的迅猛发展,越来越多人热衷于在网上发布文案,文案用于分享...
定点投篮大赛策划书 定点投篮大赛策划书  一、活动主题:大学生定点投篮大赛  二、策划主办单位:经贸系学生会  参赛人员...
教师节简短的文案 教师节简短的文案(通用60句)  在日常学习、工作和生活中,大家都知道一些经典的文案吧,文案用于记录...
国庆节的文案 关于国庆节的文案(通用190句)  随着社交网络的发展,大家都接触过比较经典的文案吧,文案具有文字简...