C/C++笔试题(11)

 

(慧通)


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

1.static有什么用途?(请至少说明两种) 1)在函数体,一个被声明为静态的变量在这一函数被调用过程维持其值不变。 2) 在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所用函数访问,但不能被模块外其它函数访问。它是一个本地的全局变量。 3) 在模块内,一个被声明为静态的函数只可被这一模块内的其它函数调用。那就是,这个函数被限制在声明它的模块的本地范围内使用 2.引用与指针有什么区别? 1) 引用必须被初始化,指针不必。 2) 引用初始化以后不能被改变,指针可以改变所指的对象。 3) 不存在指向空值的引用,但是存在指向空值的指针。 3.描述实时系统的基本特性 在特定时间内完成特定的任务,实时性与可靠性。 4.全局变量和局部变量在内存是否有区别?如果有,是什么区别? 全局变量储存在静态数据库,局部变量在堆栈。 5.什么是平衡二叉树? 左右子树都是平衡二叉树 且左右子树的深度差值的绝对值不大于1。 6.堆栈溢出一般是由什么原因导致的? 没有回收垃圾资源。 7.什么函数不能声明为虚函数? constructor函数不能声明为虚函数。 8.冒泡排序算法的时间复杂度是什么? 时间复杂度是O(n^2)。 9.写出float x 与“零值”比较的if语句。 if(x>0.000001&&x<-0.000001) 10.Internet采用哪种网络协议?该协议的主要层次结构? Tcp/Ip协议 主要层次结构为: 应用层/传输层/网络层/数据链路层/物理层。 11.Internet物理地址和IP地址转换采用什么协议? ARP (Address Resolution Protocol)(地址解析協議) 12.IP地址的编码分为哪俩部分? IP地址由两部分组成,网络号和主机号。不过是要和“子网掩码”按位与上之后才能区分哪些是网络位哪些是主机位。 13.用户输入M,N值,从1至N开始顺序循环数数,每数到M输出该数值,直至全部输出。写出C程序。 循环链表,用取余操作做 14.不能做switch()的参数类型是: switch的参数不能为实型。 1.写出判断ABCD四个表达式的是否正确, 若正确, 写出经过表达式 a的值(3分) int a = 4; (A)a += (a++); (B) a += (++a) ;(C) (a++) += a;(D) (++a) += (a++); a = ? 答:C错误,左侧不是一个有效变量,不能赋值,可改为(++a) += a; 改后答案依次为9,10,10,11 2.某32位系统下, C++程序,请计算sizeof 的值(5分). char str[] = “http://www.ibegroup.com/” char *p = str ; int n = 10; 请计算 sizeof (str ) = ?(1) sizeof ( p ) = ?(2) sizeof ( n ) = ?(3) void Foo ( char str[100]){ 请计算 sizeof( str ) = ?(4) } void *p = malloc( 100 ); 请计算 sizeof ( p ) = ?(5) 答:(1)17 (2)4 (3) 4 (4)4 (5)4 3. 回答下面的问题. (4分) (1).头文件的 ifndef/define/endif 干什么用?预处理 答:防止头文件被重复引用 (2). #i nclude 和 #i nclude “filename.h” 有什么区别? 答:前者用来包含开发环境提供的库头文件,后者用来包含自己编写的头文件。 (3).在C++ 程序调用被 C 编译器编译后的函数,为什么要加 extern “C”声明? 答:函数和变量被C++编译后在符号库的名字与C语言的不同,被extern "C"修饰的变 量和函数是按照C语言方式编译和连接的。由于编译后的名字不同,C++程序不能直接调 用C 函数。C++提供了一个C 连接交换指定符号extern“C”来解决这个问题。 (4). switch()不允许的数据类型是? 答:实型 4. 回答下面的问题(6分) (1).Void GetMemory(char **p, int num){ *p = (char *)malloc(num); } void Test(void){ char *str = NULL; GetMemory(&str, 100); strcpy(str, "hello"); printf(str); } 请问运行Test 函数会有什么样的结果? 答:输出“hello” (2). void Test(void){ char *str = (char *) malloc(100); strcpy(str, “hello”); free(str); if(str != NULL){ strcpy(str, “world”); printf(str); } } 请问运行Test 函数会有什么样的结果? 答:输出“world” (3). char *GetMemory(void){ char p[] = "hello world"; return p; } void Test(void){ char *str = NULL; str = GetMemory(); printf(str); } 请问运行Test 函数会有什么样的结果? 答:无效的指针,输出不确定 5. 编写strcat函数(6分) 已知strcat函数的原型是char *strcat (char *strDest, const char *strSrc); 其strDest 是目的字符串,strSrc 是源字符串。 (1)不调用C++/C 的字符串库函数,请编写函数 strcat 答: VC源码: char * __cdecl strcat (char * dst, const char * src) { char * cp = dst; while( *cp ) cp++; /* find end of dst */ while( *cp++ = *src++ ) ; /* Copy src to end of dst */ return( dst ); /* return dst */ } (2)strcat能把strSrc 的内容连接到strDest,为什么还要char * 类型的返回值? 答:方便赋值给其他变量 6.MFCCString是类型安全类么? 答:不是,其它数据类型转换到CString可以使用CString的成员函数Format来转换 7.C++为什么用模板类。 答:(1)可用来创建动态增长和减小的数据结构 (2)它是类型无关的,因此具有很高的可复用性。 (3)它在编译时而不是运行时检查数据类型,保证了类型安全 (4)它是平台无关的,可移植性 (5)可用于基本数据类型 8.CSingleLock是干什么的。 答:同步多个线程对一个数据类的同时访问 9.NEWTEXTMETRIC 是什么。 答:物理字体结构,用来设置字体的高宽大小 10.程序什么时候应该使用线程,什么时候单线程效率高。 答:1.耗时的操作使用线程,提高应用程序响应 2.并行操作时使用线程,如C/S架构的服务器端并发线程响应用户的请求。 3.多CPU系统,使用线程提高CPU利用率 4.改善程序结构。一个既长又复杂的进程可以考虑分为多个线程,成为几个独立或半独 立的运行部分,这样的程序会利于理解和修改。 其他情况都使用单线程。 11.Windows是内核级线程么。 答:见下一题 12.Linux有内核级线程么。 答:线程通常被定义为一个进程代码的不同执行路线。从实现方式上划分,线程有两 种类型:“用户级线程”和“内核级线程”。 用户线程指不需要内核支持而在用户程序 实现的线程,其不依赖于操作系统核心,应用进程利用线程库提供创建、同步、调度 和管理线程的函数来控制用户线程。这种线程甚至在象 DOS 这样的操作系统也可实现 ,但线程的调度需要用户程序完成,这有些类似 Windows 3.x 的协作式多任务。另外一 种则需要内核的参与,由内核完成线程的调度。其依赖于操作系统核心,由内核的内部 需求进行创建和撤销,这两种模型各有其好处和缺点。用户线程不需要额外的内核开支 ,并且用户态线程的实现方式可以被定制或修改以适应特殊应用的要求,但是当一个线 程因 I/O 而处于等待状态时,整个进程就会被调度程序切换为等待状态,其他线程得不 到运行的机会;而内核线程则没有各个限制,有利于发挥多处理器的并发优势,但却占 用了更多的系统开支。 Windows NT和OS/2支持内核线程。Linux 支持内核级的多线程 13.C++什么数据分配在栈或堆,New分配数据是在近堆还是远堆? 答:栈: 存放局部变量,函数调用参数,函数返回值,函数返回地址。由系统管理 堆: 程序运行时动态申请,new 和 malloc申请的内存就在堆上 14.使用线程是如何防止出现大的波峰。 答:意思是如何防止同时产生大量的线程,方法是使用线程池,线程池具有可以同时提 高调度效率和限制资源使用的好处,线程池的线程达到最大数时,其他线程就会排队 等候。 15函数模板与类模板有什么区别? 答:函数模板的实例化是由编译程序在处理函数调用时自动完成的,而类模板的实例化 必须由程序员在程序显式地指定。 16一般数据库若出现日志满了,会出现什么情况,是否还能使用? 答:只能执行查询等读操作,不能执行更改,备份等写操作,原因是任何写操作都要记 录日志。也就是说基本上处于不能使用的状态。 17 SQL Server是否支持行级锁,有什么好处? 答:支持,设立封锁机制主要是为了对并发操作进行控制,对干扰进行封锁,保证数据 的一致性和准确性,行级封锁确保在用户取得被更新的行到该行进行更新这段时间内不 被其它用户所修改。因而行级锁即可保证数据的一致性又能提高数据操作的迸发性。 18如果数据库满了会出现什么情况,是否还能使用? 答:见16 19 关于内存对齐的问题以及sizof()的输出 答:编译器自动对齐的原因:为了提高程序的性能,数据结构(尤其是栈)应该尽可能 地在自然边界上对齐。原因在于,为了访问未对齐的内存,处理器需要作两次内存访问 ;然而,对齐的内存访问仅需要一次访问。 20 int i=10, j=10, k=3; k*=i+j; k最后的值是? 答:60,此题考察优先级,实际写成: k*=(i+j);,赋值运算符优先级最低 21.对数据库的一张表进行操作,同时要对另一张表进行操作,如何实现? 答:将操作多个表的操作放入到事务进行处理 22.TCP/IP 建立连接的过程?(3-way shake) 答:在TCP/IP协议,TCP协议提供可靠的连接服务,采用三次握手建立一个连接。   第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状 态,等待服务器确认; 第二次握手:服务器收到syn包,必须确认客户的SYN(ack=j+1),同时自己也发送一个 SYN包(syn=k),即SYN+ACK包,此时服务器进入SYN_RECV状态;   第三次握手:客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1) ,此包发送完毕,客户端和服务器进入ESTABLISHED状态,完成三次握手。 23.ICMP是什么协议,处于哪一层? 答:Internet控制报文协议,处于网络层(IP层) 24.触发器怎么工作的? 答:触发器主要是通过事件进行触发而被执行的,当对某一表进行诸如UPDATE、 INSERT 、 DELETE 这些操作时,数据库就会自动执行触发器所定义的SQL 语句,从而确保对数 据的处理必须符合由这些SQL 语句所定义的规则。 25.winsock建立连接的主要实现步骤? 答:服务器端:socker()建立套接字,绑定(bind)并监听(listen),用accept() 等待客户端连接。 客户端:socker()建立套接字,连接(connect)服务器,连接上后使用send()和recv( ),在套接字上写读数据,直至数据交换完毕,closesocket()关闭套接字。 服务器端:accept()发现有客户端连接,建立一个新的套接字,自身重新开始等待连 接。该新产生的套接字使用send()和recv()写读数据,直至数据交换完毕,closesock et()关闭套接字。 26.动态连接库的两种方式? 答:调用一个DLL的函数有两种方法: 1.载入时动态链接(load-time dynamic linking),模块非常明确调用某个导出函数 ,使得他们就像本地函数一样。这需要链接时链接那些函数所在DLL的导入库,导入库向 系统提供了载入DLL时所需的信息及DLL函数定位。 2.运行时动态链接(run-time dynamic linking),运行时可以通过LoadLibrary或Loa dLibraryEx函数载入DLL。DLL载入后,模块可以通过调用GetProcAddress获取DLL函数的 出口地址,然后就可以通过返回的函数指针调用DLL函数了。如此即可避免导入库文件了 。 27.IP组播有那些好处? 答:Internet上产生的许多新的应用,特别是高带宽的多媒体应用,带来了带宽的急剧 消耗和网络拥挤问题。组播是一种允许一个或多个发送者(组播源)发送单一的数据包 到多个接收者(一次的,同时的)的网络技术。组播可以大大的节省网络带宽,因为无 论有多少个目标地址,在整个网络的任何一条链路上只传送单一的数据包。所以说组播 技术的核心就是针对如何节约网络资源的前提下保证服务质量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值