深圳金华业C++笔试题

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

选择题:SSs

1、 下面哪个不是成员函数()

构造函数,析构函数 , 友元函数 拷贝构造孙数

2union data {int a,int b[5],char c},struct on {char a,union data  aa,double temp}计算sizeof(union data)+sizeof(struct on)的大小()

A   B   C 45    D 52

3、怎么引用已经定义过的全局变量()

A extern   B ifndef   C define D endif

4、下面运行结果()

  Int x=1,a=b=0;

  Switch(x)

  {

Case 0 :a++;

Case 1:a++;

Default:a++;b++

}

A a=2,b=1;  B  C  D

 

5、下面运行结果是()

Int x=5;

If(x–<5)

Printf(“%d”,x);

else

 printf(“%d”,x++);

 

 

6、入栈为123456,栈大小为3,下面不可能的栈顺序的是(D)

A 123456   B 214356   C 321654  D 432156

7、下面输出结果()

Int i=0;

For(i=0;i<3,i++)

{

Switch(i)

{

Case 1: printf(“%d”,i);

Case 2: printf(“%d”,i);

Case 0:printf(“%d”,i);

}

}

8swap1(int a[2])

{

Int temp=0;

temp=a[0];a[0]=a[1];a[1]=temp;

}

Swap2(int a,int b)

{

Int temp;

temp=a;a=b;b=temp;

}

Function()

{

Int a[1]={3,5}

Swap1(a);

Printf(“%d,%dn”,a[0],a[1]);

Swap(a[0],a[1]);

Printf(“%d,%dn”,a[0],a[1]);

}

 

9f1(int *p,long &q)调用正确的是()

Int a;long b;

10int a[3][3];int *p=&a[0][0];

for(int i=0;i<9;i++)

{

p[i]=i+1;

}

a[1][2]的值为:

11 SQL中关于NULL语法错误的是

12int *p=a,*q;

q=*b,

a,b分别为什么,

判断题:

1、 char str[]=”hello word”,char *p=(char *)malloc(sizeof(char)),

strlen(str)=11,strlen(p)没结果,sizeof(p)=4;

2、 main()并一定是最先执行,main()运行完还可以执行其它函数;

3、 一个类必需有一个无参的构造函数;

 

 

 

 

简答题:

1、 下面哪个执行效率最快i=i+1,i++,i+=1;为什么

2、 CC++有什么区别,你对面向对象有什么认识,

3、 网络编程中,多进程与多线程有什么区别,

4-5(只记住知识点) 基类指针与派生类指针,隐藏、多态等,基类构造函数与派生类构造函数调用顺序

 

编程题:

1、 实现单链表反转或删除某个结点,

反转:

LINK *link;

NODE *p1=link->head,*p2=p1->next,*p3=NULL;

P1->next=NULL;

While(p2)

{

P3=p2->next;

P2->next=p1;

P1=p2;

P2=p3;

}

Link->head->next=p1;

删除某个结点:

 

2、 实现完整的构造函数、析构函数,等号运算符重载

string::string()

{

data=NULL;

}

string::~string()

{

if(data!=NULL)

{

delete [] data;

data=NULL;

}

}

string::operator=(const string &test)

{

if(test.data==NULL||strlen(test.data)==0)

{

if(this->data!=NULL)

{

delete [] this->data;

This->data=NULL:

}

}

else

{

this->data = new char [strlen(test.data)+1];

strcpy(this->data,test.data);

}

}

3、 实现字符串的反转,例如abcde,转成edcba,注意时间复杂度与空间复杂度

char str[]=”abcde”;

int len = strlen(str);

int i=0,j=0;

for(i=0,j=len-1;i<j;i++,j–)

{

str[i]+=str[j];

str[j]=str[i]-str[j];

str[i]-=str[j]

}

评论列表
文章目录