linux C经典面试题十四

港湾兴业工程师入职面试题

 

1.             第一部分C语言和数据结构(每题2分,共20分)

1.1

  二叉树的前序,中序和后序遍历法最适合采用(1)-----来实现。

查找树中,由根结点到所有其他结点的路径长度总和称为(2)------。

而上述路径长度总和达到最小的树称为(3)------,它一定是(4)------。

      在关于树的几个叙述中,只有(5)------是正确的。

 

(1)A递归程序     B迭代程序      C队列操作      D栈操作

(2)A路径和       B内部路径长度  C总深度        D深度和

(3)A   B-树       B  B+树        C丰满树        D穿线树

(4)A   B-树       B 平衡树       C非平衡树      D穿线树

(5)A.用指针方式储存有n个结点的二叉树,至少要n+1个指针。

     B.m阶B-树中,每个非椰子结点的后件个数大于或等于[m/2]。

     C.m阶B-树中,具有K个后件的结点,必含有K-1个键值。

     D.平衡树一定是丰满树。

 

1.2

设有说明语句:

      enum color{red,yellow,blue,white};

那么yellow的值为(   )

 

A .1        B.2             C.YELLOW     Dyellow

 

 

1.3

 

i=4,那么语句

 

   j=i+++1

执行后的结果应该是(    )

A.i=4,j=6   B.i=5,j=5   C.i=5,j=6   D.i=6,j=6

 

1.4

 

设a,b为整型数,且a=2,b=4,则表达式(a/b?b+a:b-a)的值为( C  )

 

A . 0.5    B. 6      C. 2   D 此表达式错误

 

1.5

对于说明语句

   int*p,array[10];

后续程序中不容许出现的语句是(  C )

A.p=array   B.*p=array[0]      C.p=&array    D.p=&array[0]

 

1.6

 

设n=10,i=4,则赋值运算

 

   n%=i+1

执行后n的值为(    )

A.0        B.1         C.2       D.3

 

2.第二部分  逻辑题(每题2分,共20分)

 

2.1

 

在中国东北有这样两个村落,赵村所有的村民都是白天祭祀祖先,而李庄的人都是晚上祭祀祖先,能肯定的没人在白天和晚上都祭祀祖先的。我们也知道赵李明是晚上祭祀祖先的人,那么以下哪个选项是正确的( B  )

A.      赵李明是赵村的人。

B.      赵李明不是赵村的人。

C.      赵李明是李庄的人。

D.      赵李明不是李庄的人。

E.       赵李明既不是赵村的人,也不是李庄的人。

 

 

2.2

     相传在古时候某国的国民都分别居住在两个怪城里,一座“真城”,一座“假城”。凡真城的人个个都说真话,而假城的人个个都说假话。一位知道情况的外国游客来到其中一个城市,他只问了一个问题就知道自己来到是哪个城了。下面哪个话最恰当(E  )

A.      你是真城人吗?

B.      你是假城人吗?

C.      你是说真话的人吗?

D.      你是说假话的人吗?

E.       你是这个城市的人吗?

 

2.3

  

设“并非无奸不商”为真,则下面哪个选项一定为真。( D   )

A.      所有商人都是奸商。

B.      所有商人都不是奸商。

C.      并非所有商人不是奸商。

D.      并非所有商人是奸商。

E.       有的商人不是奸商。

 

2.4

 

The works of philosophers K,R,S,and W will be discussed in a series of four seminars.Each seminar in the series will be on exactly one of these philosophers, and no philosopher will be the focus of more than one of the seminers.The order in which these seminars can be conducted is constrained by the following conditions:

The seminar on W must be either the first or the last in the series.

The seminar on R must be conducted at some time before the seminar on S or at some time before the seminar on W but not before both.

The seminar on K cannot be the one immediately following the seminar on S.

 

(1)     Which of the following could be the order in whith the four seminars are conducted?B

A.      K,R,S,W

B.      S,R,K,W

C.      S,R,W,K

D.      W,R,S,K

E.       W,S,R,K

(2)     If the frist seminar is on W,which of the following must be true?( D  )

A.      The seminar on R is immediately after the seminar on W.

B.      The seminar on S is immediately after the seminar on R.

C.      The seminar on K is conducted at some time after the seminar on R.

D.      The seminar on R is conducted at some time after the seminar on K.

E.       The seminar on S is conducted at some time after the seminar on K.

 

(3)      If the seminar on S is conducted at some time before the seminar on K,which of the following must be true?(  B )

 

A.      The first seminar is on W.

B.      The second seminar is on R.

C.      The second seminar is on S.

D.      The third seminar is on R.

E.       The forth seminar is on K.

(4)      If the seminar on K is the first seminar in the series,whith of the following must be true?(  BE  )

A.      The second seminar is on R.

B.      The second seminar is on S.

C.      The seminar on K is immediately before the seminar on R.

D.      The seminar on S is conducted at some time after the seminar on R.

E.       The seminar on W is conducted at some time before the seminar on R.

 

(5)     Which of the following can be true of the seminar series?( D )

 

 

A.      The last seminar is on K.

B.      The third seminar is on S.

C.      The first seminar is on S and the third seminar is on R.

D.      The seminar on S is conducted at some time before the seminar on K.

E.       The seminar on W is immediately after the seminar on S.

(6)     If the seminar on S is not the last seminar in the series,which of the following must be true?( E )

 

A.      The first seminar is on K.

B.      The first seminar is on S.

C.      The second seminar is on K.

D.      The second seminar is on R.

E.       The last seminar is on W.

 

2.5

小赵比小钱个子高:小孙不小李个子高:小李个子不如小周高:小钱和小周个子正好一样高。如果上述这些陈述都是对的,那么,下列那项也是对的?(  )

 

A. 小孙比小周个子高。

B. 小孙比小赵个子高。

C. 小钱比小孙个子矮。

D. 小赵比小李个子高。

E.  小钱比小李个子矮。

 

3.     第三部分  操作系统(每题2分,共20分)

 

3.1

 

计算机指令系统往往具有多种寻址方式。操作数就是指令的一部分称为--(1)寻址,操作数地址在指令中称为--(2)寻址。当操作数地址在寄存器中,就采用--(3)寻址方式。假设基址寄存器的内容为2000H,变址积存器的内容为03A0H,指令的地址码部分为3FH,当前正在执行的指令所在地址为2B00H。若采用相对寻址方式,则数据实际地址为--(4),若采用变址寻址,并考虑基址,数据的实际地址为--(5)。

C(1)A 直接      B 运算器      C 立即数      D 指令

A(2)A 直接      B 间接        C 堆栈        D内存

C(3)A 直接      B 寄存器      C 寄存器间址  D变址

C(4)A 23A0H     B  4B00H      C 2B3FH     D 2EA0H

B(5)A 23DFH     B 4B3FH        C23A0H     D203FH

 

3.2.

 

操作系统中,可以并行工作的基本单位是--(1),--(1)也是核心调度及资源分配的基本单位,它是由--(2)组成的,它与程序的重要区别之一是--(3)。当因资源竞争可能会引起死锁时,可以有两种策略对付;--(4)和--(5)。其中--(4)付出的代价较高。

C(1)A.作业      B.函数       C.进程      D.过程

C(2)  B.程序,数据和PCB。  B.程序,数据和标识符  C.程序,标识符和PCB  D.数据,标识符和PCB。

B(3) A.程序有状态,而它没有。B它有状态,而程序没有。C 程序可占有资源,而它不可。D.它能占有资源,而程序不能。

AC(4),(5) .A.死锁的避免和预防。B修改控制字。C 死锁的检测和修复。D撤消锁。E 改写Config文件。F 重新启动。

 

 

4.第四部分 TCP/IP(每题两分,共10分)

 

4.1

国际标准化组织OSI基本参考模型有--(1)层。IP,TCP和EHTERNET分别是对应于该模型中的--(2),--(3)和--(4)的协议。在因特网协议组中,与TCP在同一层的协议还有--(5)。

C(1)A 5      B 6        C7          D8

A(2)A网络层 B运输层    C会话层     D媒体访问控制层

B(3)A网络层 B运输层    C会话层     D媒体访问控制层

D(4)A应用层 B物理层    C表示层     D数据链路层

A(5)A  UDP  B   NCP    C ARP        D ICMP

 

 

5. 第五部分  改错和编程

 

5.1   请指出下列程序中的错误并改正

 

从内存地址为0x80000000顺序读取256个字符,存入动态分配的内存中

 

main( )

{

 char*p1,p2=(char*)0x80000000;

 int num=256;

unsigned char i;

 *p1=malloc(num);

 if(p1=NULL)exit(-1);

 for(i=0;i<num;i++){

   *p1++=*++p2;

}

}

 

 

5.2   请指出下列程序中的错误并改正

 

根据命令行参数的第1个字符,调用宏,实现变量先左移后相加。

 

  #define add(x,y,z)

        { \

         x<<z+y;\

        }

main(int argc,char argv[])

{

 int a=10,b=5,t;

 switch(argv[1][0])

{

   case’1’:t=add(a,b,1);

   case’2’:t=add(a,b,2);

   default:break;

  }

}

 

5.3  阅读下列程序或函数说明和C代码,将应填入---(n)处的字句写在答题纸的对应栏内

 

[程序说明]

本程序中的函数factor(m,fac,cp)用来计算正数m(m>2)的除自身以外的所有不同因子的和。该函数返回因子和,并把各因子从小到大依次存放在数组fac中,其因子个数存入在cp所指的变量中。

 

例如 m=16,求得的因子为

 

(1,2,4,8)

 

因子和为15,因子个数为4。

程序假定正整数m的不同因子个数不会超过100个。

[程序]

 

#include

#define N 100

long factor(int m,int fac[],int*cp)

{

int c1,c2,i,k;

long s;

fac[0]=1;

for(c1=s=1,c2=N-1,  i= 2    ;;)

{

k=m/i;

if(  m%i == 0   )

if(  i<k         )

{

fac[c1++]=i ;

fac[c2--]=k;

s+=i;

}

i++;

if(i>k)break;

}

for(c2++; c2<=N-1; c2++)

{

fac[c1++] = fac[c2];

s +=fac[c2];

}

cp=c1;

return    ;

}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值