[海康威视软件测试笔试题]题目: 1. 测试用例的设计方法有哪些?请阐述判定表法设计测试用例的步骤。 2. 自动化测试框架有哪几种? 3. 测试覆盖率分为哪几种统计方式?分别是什么? 4. 什么是FMEA? 5. 请...+阅读
1、
10、
10、
4、4四个数,怎么算出24点?(10*10-4)/4=24
2、下列表达式在32位机器编译环境下的值()class A{};class B{public:B();virtual ~B();};class C{private:#pragma pack(4)int i;short j;float k;char l[64];long m;char *p;#pragma pack()};class D{private:#pragma pack(1)int i;short j;float k;char l[64];long m;char *p;#pragma pack()};int main(void){printf(%d\n,sizeof(A));printf(%d\n,sizeof(B));printf(%d\n,sizeof(C));printf(%d\n,sizeof(D));return 0;}class A{};class B{public:B();virtual ~B();};class C{private:#pragma pack(4)int i;short j;float k;char l[64];long m;char *p;#pragma pack()};class D{private:#pragma pack(1)int i;short j;float k;char l[64];long m;char *p;#pragma pack()};int main(void){printf(%d\n,sizeof(A));printf(%d\n,sizeof(B));printf(%d\n,sizeof(C));printf(%d\n,sizeof(D));return 0;}A、
1、
4、8
4、82 B、
4、
4、8
2、84 C、
4、
4、8
4、82 D、
1、
4、8
2、82
3、以下程序在32位机器下运行的结果是()#pragma pack(4)struct info_t{unsigned char version;unsigned char padding;unsigned char extension;unsigned char count;unsigned char marker;unsigned char payload;unsigned short sequence;unsigned int timestamp;unsigned int ssrc;};union info_u{unsigned char version;unsigned char padding;unsigned char extension;unsigned char count;unsigned char marker;unsigned char payload;unsigned short sequence;unsigned int timestamp;unsigned int ssrc;};#pragma pack()int main(void){printf(%d\n,sizeof(info_t));printf(%d\n,sizeof(info_u));return 0;}#pragma pack(4)struct info_t{unsigned char version;unsigned char padding;unsigned char extension;unsigned char count;unsigned char marker;unsigned char payload;unsigned short sequence;unsigned int timestamp;unsigned int ssrc;};union info_u{unsigned char version;unsigned char padding;unsigned char extension;unsigned char count;unsigned char marker;unsigned char payload;unsigned short sequence;unsigned int timestamp;unsigned int ssrc;};#pragma pack()int main(void){printf(%d\n,sizeof(info_t));printf(%d\n,sizeof(info_u));return 0;}A、12 12 B、12 4 C、16 4 D、16 12 E、16
14、以下表达式result的值是()#define VAL1(a,b) a*b#define VAL2(a,b) a/b--#define VAL3(a,b) ++a%bint a = 1;int b = 2;int c = 3;int d = 3;int e = 5;int result = VAL2(a,b)/VAL1(e,b)+VAL3(c,d);#define VAL1(a,b) a*b#define VAL2(a,b) a/b--#define VAL3(a,b) ++a%bint a = 1;int b = 2;int c = 3;int d = 3;int e = 5;int result = VAL2(a,b)/VAL1(e,b)+VAL3(c,d);A、-2 B、1 C、0 D、2
5、请写出以下程序的输出(5分)void swap_1(int a , int b){int c;c = a;a = b;b = c;return ;}void swap_2(int a , int b){int c;c = a;a = b;b = c;return ;}void swap_3(int *a , int *b){int c;c = *a;*a = *b;*b = c;return ;}int main(void){int a = 100;int b = 200;swap_1(a , b);printf(a = %d , b = %d\n,a , b);swap_2(a , b);printf(a = %d , b = %d\n,a , b);swap_3(a , b);printf(a = %d , b = %d\n,a , b);return 0;}void swap_1(int a , int b){int c;c = a;a = b;b = c;return ;}void swap_2(int a , int b){int c;c = a;a = b;b = c;return ;}void swap_3(int *a , int *b){int c;c = *a;*a = *b;*b = c;return ;}int main(void){int a = 100;int b = 200;swap_1(a , b);printf(a = %d , b = %d\n,a , b);swap_2(a , b);printf(a = %d , b = %d\n,a , b);swap_3(a , b);printf(a = %d , b = %d\n,a , b);return 0;}输出结果:a = 100 , b = 200a = 200 , b = 100a = 100 , b = 200
6、下面的程序是否有问题,如有问题,请重构代码(5分)void test_type(bool b , const char *p , float f){if(!b){return ;}else if(!p){return ;}else if(!f){return ;}}void test_type(bool b , const char *p , float f){if(!b){return ;}else if(!p){return ;}else if(!f){return ;}}修改如下:void test_type(bool b , const char *p , float f){if(!b){return ;}else if(!p){return ;}else if(f -1e-10 f 1e-10){return ;}}void test_type(bool b , const char *p , float f){if(!b){return ;}else if(!p){return ;}else if(f -1e-10 f 1e-10){return ;}}
7、请指出以下程序有什么问题(5分)void test_mem(){char *p = new char[64];delete p;p = NULL;return ;}void test_mem(){char *p = new char[64];delete p;p = NULL;return ;}应该修改为 delete[]p; p指向的是一个字符型的数组空间,原来的代码只是简单的释放了指向申请空间的指针,并没有释放申请的空间,容易造成内存崩溃。
回收用 new 分配的单个对象的内存空间的时候用 delete,回收用 new[] 分配的一组对象的内存空间的时候用 delete[]。
延伸阅读:
2013年海康威视校园招聘嵌入式开发笔试题A卷 1.栈 stack和堆 heap有什么区别,写两个函数分别在栈上和堆上分配内存,在堆上分配内存应注意哪些问题? 2. 信号量是什么?有什么区别?使用信号量进行任务间通信有何优缺点?...
望海康信研发招聘笔试题计算机基础部分 1. CISC体系与RISC体系分别指什么? 2. 面向对象的三个基本特征是什么? 3. 抽象类与接口有什么区别? 4. ISO\OSI网络参考模型分哪些层? 5. 简述TCP/IP协定的...