C/C++笔试题(11)

时间:2021-12-08 13:50:39
 

(慧通)


1
写出程序把一个链表中的接点顺序倒排
typedef struct linknode
{
int data;
struct linknode *next;
}node;
//
将一个链表逆置
node *reverse(node *head)
{
node *p,*q,*r;
p=head;
q=p->next;
while(q!=NULL)
{ r=q->next;
 q->next=p;
 p=q;
 q=r;}
head->next=NULL;
head=p;
return head;
}


2 写出程序删除链表中的所有接点
void del_all(node *head)
{ node *p;
 while(head!=NULL)
 { p=head->next;
   free(head);
   head=p;
 }
 cout<<"
释放空间成功!"<<endl;
 }


3两个字符串,s,t;t字符串插入到s字符串中,s字符串有足够的空间存放t字符串
void insert(char *s, char *t, int i)
{
char *q = t;
char *p =s;
if(q == NULL)return;
while(*p!='/0')
{
p++;
}
while(*q!=0)
{
*p=*q;
p++;
q++;
}
*p = '/0';
}

void insert(char *s, char *t, int i)
{
memcpy(&s[strlen(t)+i],&s[i],strlen(s)-i);
memcpy(&s[i],t,strlen(t));
s[strlen(s)+strlen(t)]='/0';
}



分析下面的代码:
char *a = "hello";
char *b = "hello";
if(a= =b)
printf("YES");
else
printf("NO");
这个简单的面试题目,我选输出 no(对比的应该是指针地址吧),可在VCYES CNO
lz
的呢,是一个常量字符串。位于静态存储区,它在程序生命期内恒定不变。如果编译器优化的话,会有可能ab同时指向同一个hello的。则地址相同。如果编译器没有优化,那么就是两个不同的地址,则不同

 

 

写一个函数,功能:完成内存之间的拷贝
memcpy source code:
270 void* memcpy( void *dst, const void *src, unsigned int len )
271 {
272 register char *d;
273 register char *s;
27
275 if (len == 0)
276 return dst;
277
278 if (is_overlap(dst, src, len, len))
279 complain3("memcpy", dst, src, len);
280
281 if ( dst > src ) {
282 d = (char *)dst + len - 1;
283 s = (char *)src + len - 1;
284 while ( len >= 4 ) {
285 *d-- = *s--;
286 *d-- = *s--;
287 *d-- = *s--;
288 *d-- = *s--;
289 len -= 4;
290 }
291 while ( len-- ) {
292 *d-- = *s--;
293 }
294 } else if ( dst < src ) {
295 d = (char *)dst;
296 s = (char *)src;
297 while ( len >= 4 ) {
298 *d++ = *s++;
299 *d++ = *s++;
300 *d++ = *s++;
301 *d++ = *s++;
302 len -= 4;
303 }
304 while ( len-- ) {
305 *d++ = *s++;
306 }
307 }
308 return dst;
309 }
公司考试这种题目主要考你编写的代码是否考虑到各种情况,是否安全(不会溢出)
各种情况包括:
1、参数是指针,检查指针是否有效
2、检查复制的源目标和目的地是否为同一个,若为同一个,则直接跳出
3、读写权限检查
4、安全检查,是否会溢出
memcpy
拷贝一块内存,内存的大小你告诉它
strcpy
是字符串拷贝,遇到'/0'结束

/* memcpy ———
拷贝不重叠的内存块 */
void memcpy(void* pvTo, void* pvFrom, size_t size)
{
void* pbTo = (byte*)pvTo;
void* pbFrom = (byte*)pvFrom;
ASSERT(pvTo != NULL && pvFrom !
= NULL); //
检查输入指针的有效性
ASSERT(pbTo>=pbFrom+size || pbFrom>=pbTo+size);//
检查两个指针指向的内存是否重叠
while(size-->0)
*pbTo++ == *pbFrom++;
return(pvTo);
}

华为面试题:

 

怎么判断链表中是否有环?
bool CircleInList(Link* pHead)
{
if(pHead = = NULL || pHead->next = = NULL)//
无节点或只有一个节点并且无自环
return (false);
if(pHead->next = = pHead)//
自环
return (true);
Link *pTemp1 = pHead;    //step 1
Link *pTemp = pHead->next;   //step 2
while(pTemp != pTemp1 && pTemp != NULL && pTemp->next != NULL)
{
pTemp1 = pTemp1->next;   //
增量1

pTemp = pTemp->next->next;  //增量2
}
if(pTemp = = pTemp1)
return (true);
return (false);
}

1
。编写一个 C 函数,该函数在一个字符串中找到可能的最长的子字符串,且该字符串是由同一字符组成的。
char * search(char *cpSource, char ch)
{
char *cpTemp=NULL, *cpDest=NULL;
int iTemp, iCount=0;
while(*cpSource)
{
if(*cpSource == ch)
{
iTemp = 0;
cpTemp = cpSource;
while(*cpSource == ch)
++iTemp, ++cpSource;
if(iTemp > iCount)
iCount = iTemp, cpDest = cpTemp;
if(!*cpSource)
break;
}
++cpSource;
}
return cpDest;
}
2
。请编写一个 C 函数,该函数在给定的内存区域搜索给定的字符,并返回该字符所在位置索引值。
int search(char *cpSource, int n, char ch)
{
int i;
for(i=0; i<n && *(cpSource+i) != ch; ++i);
return i;
}

一个单向链表,不知道头节点,一个指针指向其中的一个节点,问如何删除这个指针指向的节点?
将这个指针指向的next节点值copy到本节点,将next指向next->next,并随后删除原next指向的节点。


#include <stdio.h>
void foo(int m, int n)
{
printf("m=%d, n=%d/n", m, n);
}

int main()
{
int b = 3;
foo(b+=3, ++b);
printf("b=%d/n", b);
return 0;
}
输出:m=7,n=4,b=7(VC6.0)
这种方式和编译器中得函数调用关系相关即先后入栈顺序。不过不同

编译器得处理不同。也是因为C标准中对这种方式说明为未定义,所以
各个编译器厂商都有自己得理解,所以最后产生得结果完全不同。
因为这样,所以遇见这种函数,我们首先要考虑我们得编译器会如何处理
这样得函数,其次看函数得调用方式,不同得调用方式,可能产生不同得
结果。最后是看编译器优化。


2.
写一函数,实现删除字符串str1中含有的字符串str2.
第二个就是利用一个KMP匹配算法找到str2然后删除(用链表实现的话,便捷于数组)


 

大唐电信


  DTT笔试题
  考试时间一小时,第一部分是填空和选择:
  1.数列6101832,问是几?


  2.某人出70买进一个x80卖出,90买回,100卖出,这桩买卖怎么样?

80+100-70-90=20  盈利20
  3.月球绕地球一圈,至少要多少时间?


  47个人用7小时挖了 7 的沟,以同样的速度在50小时挖 50 的沟要多少人?

7v7=7;  ?v50=50;两式相比?=7
  5.鱼头长9,鱼尾等于鱼头加半个鱼身,鱼身等于鱼头加鱼尾,问鱼全长多少?

3元一次不等式 简单


  6.一个小姐买了一块手表,回家发现手表比她家的表慢了两分钟,晚上看新闻的时候又发现她家的表比新闻里的时间慢了两分钟,则
  A 手表和新闻里的时间一样
  B 手表比新闻里的时间慢
  C 手表比新闻里的时间快


  7.王先生看到一则招聘启事,发现两个公司除了以下条件不同外,其他条件都相同
  A 半年年薪50万,每半年涨5
  B 一年年薪100万,每一年涨20
  王先生想去一家待遇比较优厚的公司,他会去哪家?


  10.问哪个袋子里有金子?
  A袋子上的标签是这样写的:B袋子上的话是对的,金子在A袋子。
  B袋子上的标签是这样写的:A袋子上的话是错的,金子在A袋子。


  113个人住酒店30块钱,经理找回5块钱,服务生从中藏了2块钱,找给每人1块钱,10&#61485;1+2=29,问这是怎么回事?


  12.三篇写作,均为书信形式。
  (1)一片中文的祝贺信,祝贺某男当了某公司xx
  (2)两篇英文的,一是说有事不能应邀,派别人去;另一篇是讨债的,7天不给钱就走人(主要考business letter格式)。

 

大唐面试试题


1
.什么是中断?中断发生时CPU做什么工作?

所谓中断是指系统发生某一事件后,CPU暂停正在执行的程序转去执行处理该事件的程序过程,处理中断事件的程序称为中断处理程序,产生中断信号的那个部件称为中断源。硬件的中断机构与处理这些中断的程序统称为中断系统。

当中断发生时,硬件机构自动地进入响应中断过程,由操作系统的中断处理程序对中断事件进行处理,具体过程如下:
·保存现场

系统开辟现场区,并将现场区组织成""结构,当中断响应时,(1)硬件结构自动将PSPC寄存器的内容压人栈中作为现场信息保存起来。(2)根据发生的中断,硬件从指定的中断向量单元中取出PSPC内容,分别装人PSPC寄存器,同时正确填人路寄存器的"当前状态""先前状态"字段。
·分析原因,转中断处理程序
不同原因产生的中断事件要进行不同的处理,根据中断的路寄存器内容得出发生该种中断的具体原因。转人相对应的申断处理程序运行。
·恢复现场
在多级中断系统中,考虑退回当前中断时,必须依据原先被中断的程序,完成不同的工作,中断处理结柬后,软件必须退出中断。如果此次是高级中断,并且被中断的程序是一个低级中断处理程序,则此次中断应返回到该低级中断处理程序。如果原来被中断的是用户程序,则退出中断前应先考虑进行一次调度选择,以挑选出更适合在当前情况下运行的新程序。

2CPU在上电后,进入操作系统的main()之前必须做什么工作?

整个系统对开发环境以及各种变量的初始化,包括了变量空间的分配,cpu内部寄存器的初始化,总线的初始化等等,总之,只有等系统初始化完成以后,我们的c语言的main才能被识别和执行下来

 

3.简述ISO OSI的物理层Layer1,链路层Layer2网络Layer3的任务。


4
.有线电话和无线电话有何区别?无线电话特别需要注意的是什么?


5
.软件开发五个主要step是什么?
6
.你在开发软件的时候,这5step分别占用的时间百分比是多少?
7
makefile文件的作用是什么?

Makefile 的作用是根据配置的情况,构造出需要编译的源文件列表,然后分别编译,并把目标代码链接到一起,最终形成 Linux 内核二进制文件。 

8UNIX显示文件夹中,文件名的命令是什么?能使文件内容显示在屏幕的命令是什么?

lscatmore

9.(选做)手机用户在从一个基站漫游到另一个基站的过程中,都会发生什么?

原基站与手机用户之间的链路将由新基站与手机用户之间的链路取代的过程。

 

网通笔试题


  选择题(每题5分,只有一个正确答案)
  1.中国1号信令协议属于 的协议。
  A ccs B cas C ip D atm
  2isdnpri协议全称是

  A 综合业务模拟网基速协议
  B 综合业务模拟网模拟协议
  C 综合业务数字网基率协议
  D 综合业务数字网基次协议
  3.路由协议中, 协议是用距离作为向量的。
  A ospf B bgp C is-is D rip
  4.中国智能网中,sspscp间最上层的ss7协议是

  A incs B is41b C is 41c D inap
  5dtmf全称是

  A 双音多频 B多音双频 C多音三频 D三音多频
  6.计算机的基本组成部分中,不包含下面设备的是
  A cpu B输入设备 C存储器 D接口
  7.脉冲编码调制的简称是
  A pcm B pam C (delta)M D atm
  8.普通电话线接口专业称呼是

  A rj11 B rj 45 C rs232 D bnc
  9.现有的公共数据网都采用

  A电路交换技术 B报文交换技术
  C语音插空 D分组交换
  10ss7协议中的制止市忙消息简写为
  A stb B slb C sub D spb
  简答题(每题10分)

  1.简述普通电话与IP电话的区别。
  2.简述随路信令与公路信令的根本区别。
  3.说明掩码的主要作用。
  4ss7协议中,有三大要素决定其具体定位,哪三大要素?
  5.描述ss7的基本通话过程。
  6.简述通信网的组成结构。
  7.面向连接与面向非连接各有何利弊?
  8.写出爱尔兰的基本计算公式。
  9.数据网主要有哪些设备?
  10.中国一号协议是如何在被叫号码中插入主叫号码的?

中软融鑫笔试题


  1.关于工作
  (1 你对未来的工作生活是怎样憧憬的?为何选择我公司作为求职公司?
  (2)请用不超过30个字给出一个最能让我们录用你的理由。
  (3)你认为比较理想的工作环境是怎样的?
  (4)你个人的中长期的职业发展目标是怎样的?
  2.关于社会
  (1)如果你是杨利伟,你在太空中向祖国人民说的第一句话是什么?
  (2)宋美龄女士于200310月谢世,对这位著名人士在西安事变中的态度和作用,你是如何看待的?(不超过300字)
  (3)北京*颁布的对拾金不昧者,失主要奖励相当于财产20%奖金的公告,你是如何看的?
  (4)如果给你50万元人民币,你将会用这些钱做什么?
  (5)在美国,男、女卫生间(厕所)的正确称呼为什么?请用英语写出答案。
  (6)你认为麦当劳是世界最大的汉堡生产商吗?如果不是,请说出你的观点。
  3.教育背景
  (1)你受过哪些正规的教育或培训?(自高中毕业起)
  (2)在校期间进行过哪些社会活动?
  
 
 

Delphi笔试题目


  机械类笔试试题
  1. Briefly describe what is blanking(cutting), forming, coining and embossing in stamping process.
  
2. What is metal clading?
  
3. What is the purpose of adding glass fiber to thermoplastic material?
  
4. In contrast with metal and thermoplastic material,which has a higher coefficient of thermal expansion(CTE).
  
5. The most suitable material for a integral hinge design (typical plastic thickness=0.25 to 0.5mm at hinge)
  
6. Can a bending load makes both compressive and tensile stress in a member?
  
7. What is the design criteria used in plastics catch/snap?
  
8. What is FEA?
  
9. Why is natural frequency important in vibration analysis?
  10. What is the deflection equation of a cantilever beam fixed at one edge?

EE笔试试题


  1. Name 3 Vehicle Buses.
  
2. Name 2 possible sources of Electromagnetic interference on Electronics Circuit ASM.
  
3. Wavelength for 12MHz frequency signal is____
  
4. Name 2 important considerations for car radio performan -ce related to audio signal processing under multipath condition?
  
5. What is the typical FM receiver RF signal strength to achieve 30dB S/N for car radio?
  
6. When a radio is tuned to 98.1 MHz & with a LO of 108.8 MHz, what is the image frequency?
  
7. For a system with a matched impedance, what is the Reflection Coefficient and SWR?
  
8. Which property of the output capacitor is the primary cause of Low Drop Out(LDO) regulator loop instability?
  (1
Equivalent series resistance(ESR)
  (2
Effective series inductance(ESL)
  (3
Capacitance value
  (4
Dielectric material
  
9. The switching regulator is capable of:
  (1
Higher power conversion efficiency
  (2
Providing an output voltage that is higher than the input
  (3
Generating an output boltage oppsite in polarity to the input
  (4
All of the above
  10. A linear regulator op Vin(max) = 10v, Vout(min) = 4.8v, Iout(max) = 2.5mA, Iq(max) = 2.5mA, Ta(max) = 8.5摄氏度,
The regulator is available in 3 packages.Each package has the following thermal characteristics:
  Package Rja(摄氏度/W Rjc(摄氏度/W

  SO14 125 30
  
D1P8 100 52
  Choose the most suitable package to handle the power dissipation requirement without a heat sink and why.

软件笔试题


  1. How do you code an infinite loop in C?
  
2. Volatile:
  (1
What does the keyword volatile mean? Give an example
  (2
Can a parameter be both const and volatile? Give an example
  (3
Can a pointer be volatile? Give an example
  
3. What are the values of a, b, and c after the following instructions:
  
int a=5, b=7, c;
  
c = a+++b;
  
4. What do the following declarations mean?
  (1
const int a;
  (2
int const a;
  (3
const int *a;
  (4
int * const a;
  (5
int const * a const;
  
5. Which of the following statements describe the use of the keyword static?
  (1
Within the body of a function: A static variable maintains its value between function revocations
  (2
Within a module: A static variable is accessible by all functions within that module
  (3
Within a module: A static function can only be called by other functions within that module
  
6. Embedded systems always require the user to manipulate bits in registers or variables. Given an integer variable a, write two code fragments.
  
The first should set bit 5 of a. The second shnuld clear bit 5 of a. In both cases, the remaining bits should be unmodified.
  
7. What does the following function return?
  
char foo(void)
  
{
  
unsigned int a = 6;
  
iht b = -20;
  
char c;
  
(a+b > 6) ? (c=1): (c=0);
  
return c;
  
}
  
8. What will be the output of the following C code?
  
main()
  
{
  
int k, num= 30;
  
k =(num > 5 ? (num <=10 ? 100:200): 500);
  
printf(“%d”, k);
  
}
  
9. What will the following C code do?
  
int *ptr;
  
ptr =(int *)Ox 67a 9;
  
*ptr = Oxaa55;
  
10. What will be the output of the follow C code?
  
#define product(x) (x*x)
  
main()
  
{
  
int i = 3, j, k;
  
j = product(i++);
  
k = product(++i);
  
printf(“%d %d”,j,k);
  
}
  
11. Simplify the following Boolean expression
  
!((i ==12) || (j > 15))
  
12. How many flip-flop circuits are needed to divide by 16?
  
13. Provides 3 properties that make an OS, a RTOS?
  
14. What is pre-emption?
  
15. Assume the BC register value is 8538H, and the DE register value is 62A 5H.Find the value of register BC after the following assembly operations:
  
MOV A,C
  
SUB E
  
MOV C,A
  
MOV A,B
  
SBB D
  
MOV B,A
  
16. In the Assembly code shown below
  
LOOP: MVI C,78H
  
DCR C
  
JNZ LOOP
  
HLT
  
How many times is the DCR C Operation executed?
  
17. Describe the most efficient way (in term of execution time and code size) to divide a number by 4 in assembly language
  
18. what value is stored in m in the following assembly language code fragment if n=7?
  
LDAA #n
  
LABEL1: CMPA #5
  
BHI L3
  
BEQ L2
  
DECA
  
BRA L1
  
LABEL2: CLRA
  
LABEL3: STAA #m
  
19. What is the state of a process if a resource is not available?
  
#define a 365*24*60*60
  
20. Using the #define statement, how would you declare a manifest constant that returns the number of seconds in a year? Disregard leap years in your answer.
  
21. Interrupts are an important part of embedded systems. Consequently, many compiler vendors offer an extension to standard C to support interrupts. Typically, the keyword is __interrupt. The following routine (ISR). Point out problems in the code.
  
__interrupt double compute_area (double radius)
  
{
  
double area = PI * radius * radius;
  
printf(“/nArea = %f”, area);
  
return area;
  
}
  

  
  

Hongkong Bank笔试题

 

           


  
1. Please state why you chose to follow these activities and how they have contributed to your personal development. You may wish to give details of your role whether anyone else was involved and any difficulties you encountered.
  
2. Please state how you have benefited from your work experience.
  
3. How much is your present monthly salary including allowances.
  
4. Do you need to compensate your present employer if you resign? If so, please give details.
  
5. Other than academic success, what has been your greatest achievement to date? What do you see as your personal strength, why?
  
6. Please state why the position you have applied for is appropriate for you; Why you have selected HongKong Bank and what your career objectives are.
  

 

A.T. Keaney笔试题


  1. Describe your greatest achievement in the past 4-5 years?
  
2. What are your short-term and long-term career objectives? What do you think is the most ideal job for you?
  
3. Why do you want to join A.T kearney? What do you think you can contribute to A.T kearney?
  
4. Why are you applying for a position at Arthur Anderson?
  
5. What are your expectations of our firm.
  
6. Describe your hobbies and interests.
  

Shell company笔试题


  1. How wold your colleagues/classmates describe you in five words? On what evidence would they base this assessment.
  
2. If you are asked to recruit the best graduates for shell, what would you do to attract them? What would you do to select them?
  
3. Please describe a new activity that you have initiated and implemented.Please highlight your role out.
  
4. Please describe your outstanding non-academic achieve- ments.
  
5. Please describe any other significant activities you have been involved in including organizing people.
  6. Imagine that Shell has found oil in an inland province of China, near a large river. You are responsible for planning how to transport the oil to the coast thousands of miles away. What are the main issue you would consider, and what would you do?


  

KPMG笔试题


  “The big economic difference between nuclear and fossil-fuelled power stations is that nuclear reactors are more expensive to build and decommission, but cheaper to sun. So disputes over the relative efficiency of the two systems revolve not just around prices of coal and uranium today and tomorrow, but also around the way in which future income should be compared with current income.”
1. The main difference between nuclear and fossil-fuelled power stations is an economic one.
  
TRUE
  
UNTRUE
  
CANNOT SAY
  
2. The price of coal is not relevant to discussions about the relative efficiency of nuclear reactors.
  
TRUE
  
UNTRUE
  
CANNOT SAY
  
3. If nuclear reactors were cheaper to build and decommission than fossil-fuelled power stations, they would definitely have the economic advantage.
  
TRUE
  
UNTRUE
  
CANNOT SAY
  
“At any given moment we are being bombarded by physical and psychological stimuli competing for our attention. Although our eyes are capable of handling more than 5 million bits of data per second, our brain are capable of interpreting only about 500 bits per second. With similar disparities between each of the other senses and the brain, it is easy to see that we must select the visual, auditory, or tactile stimuli that we wish to compute at any specific time.”
  
4. Physical stimuli usually win in the competition for our attention.
  
TRUE
  
UNTRUE
  
CANNOT SAY
  
5. The capacity of the human brain is sufficient to interpret nearly all the stimuli the senses can register under optimum conditions.
  
TRUE
  
UNTRUE
  
CANNOT SAY
  
6. Eyes are able to cope with a greater input of information than ears.
  
TRUE
  
UNTRUE
  
CANNOT SAY
  VERBAL ANSWER

  (1C CANNOT SAY
  (2
B UNTRUE
  (3
A TRUE
  (4
C CANNOT SAY
  (5
B UNTRUE
  (6
C CANNOT SAY
  
PartII NUMERCAL TEST
  1
Which country had the highest number of people aged 60 or over at the start of 1985?
  
A. UK
  
B. France
  
C. Italy
  
D. W.Germany
  
E. Spain
  2
What percentage of the total 15mm button production was classed as sub-standard in September?
  
AA 10.5% BB 13% CC 15% DD 17.5% EE 20% AB 23.5% AC 25%
  
AD 27.5% AE 28% BC 30.5%
  
3. How many live births occurred in 1985 in Spain and Italy together (to the nearest 1000)?
  
A. 104 000
  
B. 840 000
  C. 1 044 000
  
D. 8 400 000
  
E. 10 440 000
  
4. What was the net effect on the UK population of the live birth and death rates in 1985?
  
A. Decrease of 66 700
  
B. Increase of 752 780
  C. Increase of 84 900
  
D. Cannot Say
  
E. Increase of 85 270
  
5. By how much did the total sales value of November‘s button production vary from October‘s?
   A. 8.50
(Decrease)
  
B. 42.50 (Decrease)
  
C. 85.00 (Increase)
  
D. 27.50 (Decrease)
  
E. No change
  
6. What was the loss in potential sales revenue attributable to the production of sub-standard (as opposed to standard) buttons over the 6 month period?
  
A. 13.75
  
B. 27.50
  C. 137.50
  
D. 280.00
  
E. 275.00