叠拓测试笔试题

叠拓测试笔试题

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

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 <string.h>
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 <iostream>
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

相关文章

甲骨文(oracle)技术笔试题

技术方面,英语的和MT差不多,甲骨文(oracle)技术笔试题。 不过技术测试,主要是考java和数据库, 后面五道题, 1,什么叫Normalization.什么叫3NF,并请列出1NF和2NF.....
笔试题2018-02-01
甲骨文(oracle)技术笔试题

往年百度校园招聘笔试题

在现实的学习、工作中,我们都可能会接触到试题,借助试题可以更好地考核参考者的知识才能。什么样的试题才能有效帮助到我们呢?以下是小编整理的往年百度校园招聘笔试题,欢迎阅读与收藏。往年百度校园招聘笔试题1...
笔试题2019-05-04
往年百度校园招聘笔试题

腾讯校招面试笔试题

导语:我们很多的时候都会需要腾讯校招面试笔试题,以下是小编整理的资料,欢迎阅读参考。 腾讯校招面试笔试题1 1.有一个文件test.txt里面有四列(name class address age),问...
笔试题2014-07-04
腾讯校招面试笔试题

机械专业面试笔试题

我们再去面试的时候,公司一般都会要你做一些试题,下面是小编整理的机械专业面试笔试题,欢迎阅读。 1、举例说明尺寸链的应用 尺寸链:在零件加工或机器装配过程中,由互相联系的尺寸按一定顺序首尾相接排列而成...
笔试题2016-05-09
机械专业面试笔试题

阿里巴巴秋招在线笔试经验

2015阿里秋招在线笔试附加题-数据研发工程师20个选择,有好多行测题,老长一个,读都读晕了,阿里巴巴秋招在线笔试经验。好像好记的几个专业题。1.给出二叉树的先序遍历为ACDEFHGB,中序遍...
笔试题2017-06-07
阿里巴巴秋招在线笔试经验

网易游戏校招战略分析师笔试题

共两个小时,50道选择题+4道简答题50道选择题中,10道左右的游戏相关问题(手游端游的一些常识)+时事题25-30道左右的行测题,差不多逻辑推理、阅读理解、简单计算各三分之一剩余的题目涵...
笔试题2015-01-09
网易游戏校招战略分析师笔试题