叠拓测试笔试题

本文核心词:叠拓。

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

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

未经允许不得转载:全书网 » 叠拓测试笔试题

赞 (0)

相关网站

  • 长城华人怀思堂
  • 清东陵万佛园
  • 九里山二区公墓
  • 施孝园
  • 华夏陵园
  • 中华永久陵园
  • 珍珠源公墓
  • 灵山宝塔陵园
  • 长城华人怀思堂
  • 清东陵万佛园
  • 九里山二区公墓
  • 施孝园
  • 华夏陵园
  • 中华永久陵园
  • 珍珠源公墓
  • 灵山宝塔陵园
  • 长城华人怀思堂
  • 清东陵万佛园
  • 九里山二区公墓
  • 施孝园
  • 华夏陵园
  • 中华永久陵园
  • 珍珠源公墓
  • 灵山宝塔陵园
  • 真武山公墓
  • 大朗陵园
  • 北京墓地
  • 成都墓地
  • 院山公墓
  • 卧龙寺
  • 长松寺
  • 凤凰陵园
  • 白塔山公墓
  • 宝光塔陵公墓
  • 红枫艺术陵园
  • 金沙陵园
  • 金土坡公墓
  • 燃灯寺
  • 莲花公墓
  • 真武山公墓
  • 大朗陵园
  • 院山公墓
  • 卧龙寺
  • 长松寺
  • 凤凰陵园
  • 白塔山公墓
  • 宝光塔陵公墓
  • 红枫艺术陵园
  • 金沙陵园
  • 北京墓地
  • 成都墓地
  • 金土坡公墓
  • 燃灯寺
  • 莲花公墓