IT公司笔试面试题

 
Google中国笔试题目
 

 

1.1关于IP协议那个正确
 A IP是TCP上层协议B IP协议是应用层协议C由于两个属于同一层协议,他们之间可以直接通信DIP协议不提供可靠的通信
 1.2 关于内存正确的是
 A内存的存取速度不能低于cpu速度,否则会造成数据丢失
 B程序只有在数据和代码等被调入内存后才能运行
 C采用虚拟内存技术后程序可以在硬盘上直接运行
 D某计算机的内存容量为16MB,那么他的地址总线为24位
 1.3单链表中结点的结构为(data,link),若想删除结点p(不是头节点或者尾结点)的直接后继,则应执行下列哪个操作
 A p=p->link ; p->link=p->link->linkB p->link->link=p->link;C p=p->link->link Dp->link=p->link->link
 1.4已知x>=y and y>=z 为真,那么x>z or y=z 值为
 A真B假C无法确定Dx y z同为正数时为真
 1.5某请求被随即分配到四台机器进行处理,分配到每台机器的概率A15% B20% C 30% D 35%, 处理请求的失败概率分别为5% ,4%, 3% 2%,现在请求失败,问由C造成的概率最接近A26% B28% C 30% D 32%
 1.6假设我们用d=(a1,a2,….a5)表示无向无环图G的5个顶点的度数,下面给出的哪组值是可能的
 A{3,4,4,3,1}B{4,2,2,1,1}C{3,3,3,2,2}D{3,4,3,2,1}
 1.7设栈S和队列Q的初始状态为空,元素e1,e2,e3,e4,e5,e6一次压入栈S,一个元素出栈后即进入队列Q,若出队列的顺序为e2,e4,e3,e6,e5,e1则栈S的容量要求最小值为
 A2B3C4D5
 1.8 在堆排序算法中我们用一个数组A来模拟二叉树T,如果该A[0]存放的是T的根节点,那么A[K](K>0)的父亲节点是
 A (K-1)/2 B K/2 C(K+1)/2 D 都不对 ( via: unus.cn )
 1.9 现有如下任务需要安排在若干机器上并行完成,每个任务都有开始时间和结束时间(开始和结束时间都包括在任务执行时间内)的要求
 任务名称 开始时间 结束时间
 a 1 7
 b 8 9
 c 2 5
 d 7 11
 e 3 6
 f 7 9
 g 10 13
 则最少需要使用的机器数目为
 A1B2C3D4
 1.10 在设计一个操作系统时,哪项不是必须考虑的
 A 设备管理模块B文件系统模块C用户管理模块D进程管理模块
 2.1正整数序列Q中的每个元素都至少能被正整数a和b中的一个整除,现给定a和b,需要计算出Q中的前几项,例如,当a=3,b=5,N=6时,序列为3,5,6,9,10,12
 (1)设计一个函数void generate(int a,int b,int N ,int * Q)计算Q的前几项
 (2)设计测试数据来验证函数程序在各种输入下的正确性
 2.2 有一个由大小写组成的字符串,现在需要对他进行修改,将其中的所有小写字母排在答谢字母的前面(大写或小写字母之间不要求保持原来次序),如有可能尽量选择时间和空间效率高的算法 c语言函数原型void proc(char *str) 也可以采用你自己熟悉的语言
 2.3 已知一颗无向无环连通图T的所有顶点和边的信息,现需要将其转换为一棵树,要求树的深度最小,请设计一个算法找到所有满足要求的树的根结点,并分析时空复杂度(描述算法即可,无需代码)
 1.1关于IP协议那个正确
 A IP是TCP上层协议B IP协议是应用层协议C由于两个属于同一层协议,他们之间可以直接通信DIP协议不提供可靠的通信
 1.2 关于内存正确的是
 A内存的存取速度不能低于cpu速度,否则会造成数据丢失
 B程序只有在数据和代码等被调入内存后才能运行
 C采用虚拟内存技术后程序可以在硬盘上直接运行
 D某计算机的内存容量为16MB,那么他的地址总线为24位
 1.3单链表中结点的结构为(data,link),若想删除结点p(不是头节点或者尾结点)的直接后继,则应执行下列哪个操作
 A p=p->link ; p->link=p->link->linkB p->link->link=p->link;C p=p->link->link Dp->link=p->link->link
 1.4已知x>=y and y>=z 为真,那么x>z or y=z 值为
 A真B假C无法确定Dx y z同为正数时为真
 1.5某请求被随即分配到四台机器进行处理,分配到每台机器的概率A15% B20% C 30% D 35%, 处理请求的失败概率分别为5% ,4%, 3% 2%,现在请求失败,问由C造成的概率最接近A26% B28% C 30% D 32%
 1.6假设我们用d=(a1,a2,….a5)表示无向无环图G的5个顶点的度数,下面给出的哪组值是可能的
 A{3,4,4,3,1}B{4,2,2,1,1}C{3,3,3,2,2}D{3,4,3,2,1}
 1.7设栈S和队列Q的初始状态为空,元素e1,e2,e3,e4,e5,e6一次压入栈S,一个元素出栈后即进入队列Q,若出队列的顺序为e2,e4,e3,e6,e5,e1则栈S的容量要求最小值为
 A2B3C4D5
 1.8 在堆排序算法中我们用一个数组A来模拟二叉树T,如果该A[0]存放的是T的根节点,那么A[K](K>0)的父亲节点是
 A (K-1)/2 B K/2 C(K+1)/2 D 都不对 ( via: unus.cn )
 1.9 现有如下任务需要安排在若干机器上并行完成,每个任务都有开始时间和结束时间(开始和结束时间都包括在任务执行时间内)的要求
 任务名称 开始时间 结束时间
 a 1 7
 b 8 9
 c 2 5
 d 7 11
 e 3 6
 f 7 9
 g 10 13
 则最少需要使用的机器数目为
 A1B2C3D4
 1.10 在设计一个操作系统时,哪项不是必须考虑的
 A 设备管理模块B文件系统模块C用户管理模块D进程管理模块
 2.1正整数序列Q中的每个元素都至少能被正整数a和b中的一个整除,现给定a和b,需要计算出Q中的前几项,例如,当a=3,b=5,N=6时,序列为3,5,6,9,10,12
 (1)设计一个函数void generate(int a,int b,int N ,int * Q)计算Q的前几项
 (2)设计测试数据来验证函数程序在各种输入下的正确性
 2.2 有一个由大小写组成的字符串,现在需要对他进行修改,将其中的所有小写字母排在答谢字母的前面(大写或小写字母之间不要求保持原来次序),如有可能尽量选择时间和空间效率高的算法 c语言函数原型void proc(char *str) 也可以采用你自己熟悉的语言
 2.3 已知一颗无向无环连通图T的所有顶点和边的信息,现需要将其转换为一棵树,要求树的深度最小,请设计一个算法找到所有满足要求的树的根结点,并分析时空复杂度(描述算法即可,无需代码)
 


intel的笔试题
 

 

智力题

1.每天中午从法国塞纳河畔的勒阿佛有一艘轮船驶往美国纽约,在同一时刻纽约也有一艘轮船驶往勒阿佛。已知横渡一次的时间是7天7夜,轮船匀速航行,在同一航线,轮船近距离可见。
 请问今天中午从勒阿佛开出的船会遇到几艘从纽约来的船?

2.巴拿赫病故于1945年8月31日。他的出生年份恰好是他在世时某年年龄的平方,问:他是哪年出生的?

答案:

设他在世时某年年龄为x,则x的平方<1945,且x为自然数。其出生年份x的平方-x=x(x-1),他在世年龄1945-x(x-1)。1945的平方根=44.1,则x应为44或略小于此的数。而x=44时,x(x-1)=44×43=1892,算得其在世年龄为1945-1892=53;又x=43时,x(x-1)=43×42=1806,得其在世年龄为1945-1806=139;若x再取小,其在世年龄越大,显然不妥。故x=44,即他出生于1892年,终年53岁。
 
笔试题目

1.设计一个重采样系统,说明如何anti-alias。

2.y1(n)=x(2n),y2(n)=x(n/2),问:

如果y1为周期函数,那么x是否为周期函数?

如果x为周期函数,那么y1是否为周期函数?

如果y2为周期函数,那么x是否为周期函数?

如果x为周期函数,那么y2是否为周期函数?

3.如果模拟信号的带宽为5kHz,要用8k的采样率,怎么办。

4.某个程序在一个嵌入式系统(200M的CPU,50M的SDRAM)中已经最优化了,换到另一个系统(300M的CPU,50M的SDRAM)中运行,还需要优化吗?
5.x^4+a*x^3+x^2+c*x+d最少需要做几次乘法。

6.三个float:a,b,c

问值:

(a+b)+c==(b+a)+c

(a+b)+c==(a+c)+b

7.把一个链表反向填空。

8.下面哪种排序法对12354最快?

A. quick sort

B. buble sort

C. merge sort

9.哪种结构平均来讲获取一个值最快?

A. binary tree
B. hash table
C. stack
10.

#include
“stdafx.h”
#include <iostream.h>
struct bit
{ int a:3;
int b:2;
int c:3;
};
int main(int argc, char* argv[])
{
bit s;
char *c = (char*)&s;
*c = 0x99;
cout <<
s.a <<endl <<s.b<<endl<<s.c<<endl;
return 0;
}

Output:?
11.

挑bug,在linux下运行:
#include <stdio.h>
char
*reverse(char* str)
{
int len=0, i=0;
char *pstr=str, *ptemp,*pd;
while(*++pstr)
len++;
pstr--;
//ptemp=(char*)malloc(len+1);
ptemp=(char*)malloc(len+1);
pd=ptemp;
while(len--){
*ptemp=*pstr;
ptemp++;
pstr--;
i++;
}
*ptemp=*pstr;
ptemp++;
*ptemp=‘\0’;
return pd;
}
main()
{
char string[40]= “Hello World!”;
char *pstr=string;
printf(“%s”, pstr);
printf(“%s”, reverse(pstr));
}
实验室笔试题
1.写出下列信号的奈亏斯特频率

(1)f(t)=1+cos(2000pait)+sin(4000pait)
(2)f(t)=sin(4000pait)/pait
(3)f(t)=(sin(4000pait)的平方)/pait

2.有两个线程

void producer()
{
while(1)
{
GeneratePacket();
PutPacketIntoBuffer();
Signal(customer);
}
}
void customer()
{
while(1)
{
WaitForSignal();
if(PacketInBuffer>10)
{
ReadAllPackets();
ProcessPackets();
}
}
}
(1)有没有其他方法可以提高程序的性能

(2)可不可以不使用信号之类的机制来实现上述的功能

3.优化下面的程序

(0)sum=0
(1)I=1
(2)T1=4*I
(3)T2=address(A)-4
(4)T3=T2[T1]
(5)T4=address(B)-4
(6)T5=4*I
(7)T6=T4[T5]
(8)T7=T3*T5
(9)sum=sum+T6
(10)I=I+1
(11)IF I<20 GOTO (2)

 


ibm笔试题目
 

 

It consists of number series.In some institutes alphabetical series
is given instead of number series.Iam having number series so iam   sending that.Please go through tha alphabetical tests also.
 15.  30,28,25,20,34,28,? a:21
16.  4,8,16,32,64,128,? a:256
17.  8,16,24,32,40,48,? a:56
18.  13,11,14,12,15,13,? a:16
19.  6,18,36,108,216,648,? a:1296
20.  4,4,8,8,16,16,? a:32
21.  2,6,18,54,162,486,? a:1458
22.  4,20,35,49,62,74,? a:85
23.  10,18,15,23,20,28,? a:25
24.  4,10,8,14,12,18,? a:16
25  10,15,12,17,14,19,? a:16
part 2 consists of non-verbal reasoning (figures). So it is impossible for  me to send those.(25 questions) part 3 (quantitative)
   1.  A clerk multiplied a number by ten when it should have been divided by ten. The ans he got was 100.what should the ans have been?ans:1
    2.  If Rs20/- is available to pay for typing a research report & typist A produces 42 pages and typist B produces 28  pages.How much should typist A  receive?  a:Rs12/-
   3.   The average salary of 3 workers is 95 Rs. per week. If one earns Rs.115 and second earns Rs.65 how much is the salary of the 3rd worker.Ans.105.
    4.  A 16 stored building has 12000 sq.feet on each floor. Company A rents 7 floors and company B rents 4 floors.What is the number of sq.feet of unrented floor space.   Ans.60000
   5.  During a given week A programer spends 1/4 of his time preparing flow chart, 3/8 of his time coding and the rest of the time in debugging the programs. If he works 48 hours during the week, how many hours did he spend debugging the program.Ans.18.
   6.  A company installed 36 machines at the beginning of the year. In March they installed 9 additional machines and then disconnected 18 in August.  How many were still installed at the end of the year.  Ans. 27
   7.  A man owns 2/3 of the market research beauro business and sells 3/4 of his shares for Rs. 75000. What is the value of Business.Ans.150000
   8.  If 12 file cabinets require 18 feet of wall space, how many feet of wall space will 30 cabinets require? Ans.45
   9.  A computer printer produced 176,400 lines in a given day. If the printer was in operation for seven hours during the day, how many lines did it print per minute? Ans.420
 10.   From its total income, A sales company spent Rs.20000 for advertising, half of the remainder on commissions and had Rs.6000 left.What was its total income? Ans.32000
 11.  On Monday a banker processed a batch of cheques, on Tuesday she processedthree times as many, and on Wednesday she processed 4000 cheques. In the three days, she processed 16000 cheques. How many did she process on Tuesday? Ans.9000
 12.  The cost of four dozen proof machine ribbons and five dozen accouting machine ribbons was Rs.160/-. If one dozen accounting machine ribbons cost Rs.20/-, what is the cost of a dozen proof machine ribbons?
        Ans.Rs.15
13.  If a clerk can process 80 cheques in half an hour, how many cheques can she process in a seven and one half hour day? Ans.1200
 14.  In a library, there are two racks with 40 books per rack. On a given day
  , 30 books were issued. What fraction remained in the racks? Ans.5/8
15. The average length of three tapes is 6800 feet. None of the tapes is less than 6400 feet. What is the greatest possible length of one of the other tapes? Ans.7600                 Freshersworld.com
 16. A company rented a machine for Rs.700/- a month. Five years later  the treasurer calculated that if the company had purchased the machine and paid Rs.100/- monthly maintenance charge, the company would have saved Rs.2000/-. What was the purchase price of the machine? Ans.Rs.34000
17. Two computers each produced 48000 public utility bills in a day. One computer printed bills at the rate of 9600 an hour and the other at the rate of 7800 an hour. When the first computer finished its run, how many bills did the other computer still have to printAns.9000
18. If a salesman's average is a new order every other week, he will break the office record of the year. However, after 28 weeks, he is six orders behind schedule. In what proportion of t
 
 he remaining weeks does he have to obtain a new order to break the record? Ans.3/4
 19. On a given day, a bank had 16000 cheques returned by customers. Inspection of the first 800 cheques indicated that 100 of those 800 had errors and were therefore the available immediately for data processing. On this basis, how many cheques would be available immediately for data processing on that day? Ans.14000
20. A company figured it needed 37.8 sq.feet of carpot for its reception room
 . To allow for waste, it decided to order 20% more material than needed. Fractional parts of sq.feet cannot be ordered. At Rs.9/- a sq.feet, how much would the carpet cost? Ans.a. Rs.324 b) Rs.405 c) Rs.410 d) Rs.414 e) Rs.685
 21.A tape manufacturer reduces the price of his heavy duty tape from Rs.30/- to Rs.28/- a reel and the price of a regular tape from Rs.24/- to  Rs.23/- a reel. A computing centre normally spends Rs.1440/- a month for tapes and 3/4 of this is for heavy duty tapes. How much will they save a month under the new prices?
    Ans.Rs.87
22. In a team of 12 persons, 1/3 are women and 2/3 are men. To obtain a team with 20% women how many men should be hired?  Ans.8                                 
 23. The dimensions of a certain machine are 48" X 30" X 52". If the size of the machine is increased proportionately until the sum of its dimensions equals 156", what will be the increase in the shortest side? Ans. 6"
 24. In a certain company, 20% of the men and 40% of the women attended the annual company picnic. If 35% of all the employees are man, what percent of all the employees went to the picnic?
 Ans.33%
25. It cost a college Rs.0.70 a copy to produce a Program for the homecoming football game. If Rs.15,000/-  was received for advertisements in the programme, how many copies at Rs.0.50 a copy must be sold to make a profit of Rs.8000/- ?Ans. 35000
 reversed,颠倒的,翻转的
 clockwise,顺时针
 counterclockwise,逆时针
 exchange ,交换
 catercorner ,对角线
 diagonal,对角线
 perimeter,周长
 rectangle,长方形, 矩形
 square, 正方形
 volume, 体积
 remainder,余数
 prime,质数
 odd,奇数
 even,偶数
 periphery,外围
 diameter 直径
 radius 半径
 fraction 分数
 subtract 减法
 cube 立方
 dimension 维,尺寸,度
 


中兴笔试题
 

 

公共部分(50分)
 
  1:作业调度程序从处于( )状态的队列中选择适当的作业的作业投入运行。(3分)
 
  A 运行 B 提交 C 完成 D后备
 
  2:SQL语言中,删除一个表的命令是( )(3分)
 
  A CLEAR TABLE B DROP TABLE
 
  C DELETE TABLE D REMOVE TABLE
 
  3:ATM采用的线路复用方式为( )(3分)
 
  A 频分多路复用
 
  B 同步时分多路复用
 
  C 异步时分多路复用
 
  D 独占信道
 
  4:数据库中只存放视图的( )(3分)
 
  A操作
 
  B 对应的数据
 
  C 定义
 
  D 限制
 
  5:什么是虚拟设备?为什么在操作系统中引入虚拟设备?(10分)
 
  6:TCP为何采用三次握手来建立连接,若采用二次握手可以吗,请说明原因?(16分)
 
  7:什么是分布式数据库?(12分)
 
  C++部分(50分)
 
  1:设有“int w[3][4];”,pw是与数组名w等价的数组指针,则pw的初始化语句为________________(3分)
 
  2:要使引用pr代表变量“char *p”,则pr的初始化语句为__________________(3分)
 
  3:“零值”可以是0,0.0,FALSE或者“空指针”。例如int变量n与“零值”比较的if语句为:if(n==0),则BOLL flag与“零值”比较的if语句为______________;float x与“零值”比较的if语句为:______________。(6分)
 
  4:社有如下语句:(3分)
 
  Int x;
 
  ()
 
  *px=0;
 
  则选择以下哪条语句可将x值置为0。
 
  A int *px; B int const *px=&x;
 
  C int const px=&x; D const int *px=&x;
 
  5:设viod f1(int *m,long&n);int a;long b;则以下调用合法的是( )(3分)
 
  A f1(a,b) B f1(&a,b)
 
  C f1(a,&b) D f1(&a,&b)
 
  6:请写出如下代码的运行结果(6分)
 
  Int main()
 
  {int a,b,c,d;
 
  a=0;
 
  b=1;
 
  c=2;
 
  d=3;
 
  printf(“%d”,a+++b+c+++d++);}
 
  7:写出下面函数的功能(12分)
 
  Template<class Type>
 
  Void WE(Type a[],Type b[],int n){
 
  for(int i=0;i<n;i++) b[n-i-1]=a;}
 
  8写一段代码判断一个单向链表中是否有环。(14分)
 
  给出如下结构
 
  Struct node
 
  {steuct *next;
 
  };
 
  Typedef stuct node Node;
 
  JAVA部分(50分)
 
  1:判断下列对的是哪个( )(3分)
 
  A short s1=1;s1=s1+1
 
  B short s1=1;s1+=1

  C short s1=1;s1=s1-1
 
  D short s1=1;s1=s1*1
 
  2:main方法是Java Application程序执行的入口点,关于main方法的方法头以下哪项是合法的( )(3分)
 
  A public static void main ()
 
  B public static void main (String args)
 
  C public static int main (String []arg)
 
  D public void main (String args)
 
  3:设float x=1,y=2,z=3,则表达式y+=z--/++x的值是( )(3分)
 
  A 3.5 B 3
 
  C 4 D 5
 
  4:Math.round(11.5)=_______
 
  Math.round(-11.5)=_______(4分)
 
  5:假设x=10,y=20,z=30;计算下列表达式的值(6分)
 
  A x<10||x>10__________
 
  B !(x<y+z)||(x+10<=20)___________
 
  C z-y==x&&Math.abs(y-z)!=x_____________
 
  6:方法重建Overload和方法的重写Overriding的区别。Overload的方法是否可以改变返回值的类型?(10分)
 
  7:谈谈HashMap和Hashtable的区别(6分)
 
  8:构造一个类来描述屏幕上的一个点,该类的构成包括点x和y两个坐标,以及一些对点进行的操作,包括:取得点的坐标值,对点的坐标进行赋值,编写应用程序生成该类的对象并对其进行操作。(15分)
 

是中兴第一轮的笔试题,5个小程序,自己的C++没学好

1、 分数统计(15)

要求:

(1)输入某班级学生的姓名、分数;

(2)对(1)的分数进行降幂排列并输出;

(3)具有输入输出界面。

2、 打字程序(15)

要求:

(1)随即产生一字符串,每次产生的字符串内容、长度都不同;

(2)根据(1)的结果,输入字符串,判断输入是否正确,输出正确率;

(3)具有输入输出界面。

3、 文本编辑器(15)

要求:

(1)编辑文本;

(2)保存、打开指定位置的文本文件;

(3)具有输入输出界面。

4、 加密(15)

要求:

(1)输入任意一段明文M,以及密钥K;

(2)根据一下公式将其转换为密文C。

Ci = mi + K ,其中i = 0,1,……n-1 , K 为密钥;

(3)具有输入输出界面。

5、进制转换器(15)

要求:

(1)可输入二进制、八进制、十进制、十六进制数;

(2)将已输入的数转换成其余进制的数;

(3)具有输入输出界面。

1、打字程序

要求:
 
  (1)随即产生一个字符串,每次产生的字符串内容,长度都不同

(2)根据(1)的结果,输入字符串,判断输入是否正确,输出正确率

(3)具有输入输出界面

2、文本编辑器

要求:(1)编辑文本

(2)包存,打开指位置的文本文件

(3)具有输入输出界面

3。加密

要求:(1)输入任一段明文M,以及密钥K

(2)根据下一公式将其转换为密问C

Ci=mi+K,其中i=0,1,……n-1,K为密钥

  (3)具有输入输出界面

4,进制转换器

要求:
 
  (1)可输入二进制、八进制、十进制、十六进制;

(2)可将已输入的数转换成其余进制的数

(3)具有输入输出界面。


1.对数据库的一张表进行操作,同时要对另一张表进行操作,如何实现??

  答案:将操作多个表的操作放入到事务中进行处理

  2.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状态,完成三次握手。
 
  3.ICMP是什么协议,处于哪一层?

  答案:Internet控制报文协议,处于网络层(IP层)

  4.触发器怎么工作的?

  答案:触发器主要是通过事件进行触发而被执行的,当对某一表进行诸如UPDATE、 INSERT、 DELETE 这些操作时,数据库就会自动执行触发器所定义的SQL 语句,从而确保对数据的处理必须符合由这些SQL 语句所定义的规则。
 
  5.winsock建立连接的主要实现步骤?

  答案:服务器端:socker()建立套接字,绑定(bind)并监听(listen),用accept()等待客户端连接。客户端:socker()建立套接字,连接(connect)服务器,连接上后使用send()和recv(),在套接字上写读数据,直至数据交换完毕,closesocket()关闭套接字。
 
  服务器端:accept()发现有客户端连接,建立一个新的套接字,自身重新开始等待连接。该新产生的套接字使用send()和recv()写读数据,直至数据交换完毕,closesocket()关闭套接字。
 
  6.动态连接库的两种方式?

  答案:调用一个DLL中的函数有两种方法:

  1.载入时动态链接(load-time dynamic linking),模块非常明确调用某个导出函数,使得他们就像本地函数一样。这需要链接时链接那些函数所在DLL的导入库,导入库向系统提供了载入DLL时所需的信息及DLL函数定位。
 
  2.运行时动态链接(run-time dynamic linking),运行时可以通过LoadLibrary或LoadLibraryEx函数载入DLL。DLL载入后,模块可以通过调用GetProcAddress获取DLL函数的出口地址,然后就可以通过返回的函数指针调用DLL函数了。如此即可避免导入库文件了。
 
  7.IP组播有那些好处?

  答案:Internet上产生的许多新的应用,特别是高带宽的多媒体应用,带来了带宽的急剧消耗和网络拥挤问题。组播是一种允许一个或多个发送者(组播源)发送单一的数据包到多个接收者(一次的,同时的)的网络技术。组播可以大大的节省网络带宽,因为无论有多少个目标地址,在整个网络的任何一条链路上只传送单一的数据包。所以说组播技术的核心就是针对如何节约网络资源的前提下保证服务质量。
 

 

 

 

数据结构笔试题目总汇
 

 

第一篇 笔试题目
Intel今年笔试题
●第一道是一个编译器优化的题目。条件大致说在ZF为0或者不为0的情况下,分别有两条移位指令可以移进去。然后出了两个小题,要你优化。
●第二道是N个人围成一圈报数,报到某一个数的就出局,问你最后剩下来的那个人的号码。编程题。
●第三道大致如下:
以下两个程序哪个的performance高,并解释为什么。
a)
extern int foo(void);
int main()
{
int i;
for(i=0;i<10000;i++) foo();
return i;
}
b)
extern int foo(void);
int i;
int main()
{
for(i=0;i<10000;i++) foo();
return i;
}   
●智力题
将如下图形(边长相等,即突出的都是正方形)割成几块,再拼成一个正方形,要求最少最少。
       ---
       |     |
---      ---
|                |
---      ---
       |     |
---            
● ee试卷考的是电磁场波导,拉式变化,电容器等内容
●下面的程序是否正确,如正确,给出结果,否则,说明理由。
#include <stdio.h>
struct A{
int i;
char j;
char * ptr;
long Array[100];
char b[2];
char * c;
};
#define PRINT_ME (char *)&(((struct A *)0)->c)
void main()
{
                printf("%d\n", PRINT_ME);
}
● Intel EE的IQ测试题   
有10堆苹果,每一堆10个
其中一堆每个240g
其它每堆都是250g/个
有一把称
请你只称一次把那一堆240的苹果找出来
● Intel 的虚拟函数指针那道题
#include <iostream.h>
class CBase
{
public:
     virtual void foo()
    {           cout<<"foo in base"<<endl;
    }
    virtual void bar()
    {
        cout<<"bar in base"<<endl;
    }
};
class CChild : public CBase
{
public:
    virtual void foo()
    {         cout<<"foo in child"<<endl;
    }
    virtual void bar()
   {
        cout<<"bar in child"<<endl;
   }
};
int * get(void);
void main()
{         int c;
        void (CBase::* pVirtualPointer)(void);
        CBase base;
        CChild child;
        pVirtualPointer = CBase::foo;
        (base.*pVirtualPointer)();
        (child.*pVirtualPointer)();
        pVirtualPointer = CBase::bar;
        (base.*pVirtualPointer)();
        (child.*pVirtualPointer)();
        cin>>c;
}
●补充一下
1、何时调用拷贝构造函数 (根据一个object创建另一个object,clone)
2、构造函数是否有返回类型
3、一个4word(word=4bytes)的cache,问以下程序段cache命中率
(a)for( int i=0; i<M; i++)
for(int j=0; j< N; j++)
sum+= a[j];
(b)for( int i=0; i<M; i++)
for(int j=0; j< N; j++)
sum+= a[j];
4、以下结构是否正确,why?
u8应该是无符号8位的意思吧
struct{
u8 a;
u16 b;
u8 c;
u8 d;
u16 e;
u8 f;        
};
5、一个4×4矩阵,已知每列的和(缺第一列)和每行的和,问第一列的和。
6、用伪汇编代码说明Switch语句的jump table的原理。
7、STDCALL的含义。(sigh,记反了,应该是从右到左调用)            
● Intel今年在电子科技大学的笔试题
试题分CS和EE两套,做EE题的同学必须做CS题(但其中关于编译的题不用做)
EE的题目
1、电路设计时,什么情况下需要进行信号完整性分析?
2、用一个欧姆表怎么判断出三极管的e、b、c极?
3、简述Nyquist带通采样定理
4、你能想到的最大的影子是什么?
5、24个人要求排成6排,每排5人,如何排?
6、将1~9填入下图所示的圆圈中,使3边和相等,有多少种填法?
阐述你的思路,并用伪代码实现
   o
o o
o     o
o o o o
7、简述TCP三次握手过程,并说明为什么要3次握手
8、局域网被网桥或路由器分割成子网有什么好处?
CS的题目
1、一个有符号数与无符号数的转换问题
2、有数组a[M][N],问下面那种算法效率高
(a)for(int i=0;i<M;i++)
        for(int j=0;j<N;j++)
                xxx=a[j].........
(b)for(int i=0;i<N;i++)
        for(int j=0;j<M;j++)
                xxx=a[j].........
3、关于递归调用的一个题:
   int foo(int i)
   {
     if(i==0)
       return 0;
     reurn foo(i/2)+1
   }
   问foo(4)=?
4、一个结构体定义的问题
5、一个编译的问题,关于什么跳转表的(我是EE的,这个题不用作)
6、构造函数都不定义返回类型,对吗?
7、拷贝构造函数在什么情况下被调用?
8、说明带参数的宏和内联函数的区别
● intel在北京考的题目
面试问题:
: 你到现在为止,认为自己最大的成功和失败是什么?
: 举例说明   
#include "stdafx.h"
: : #include <iostream.h>
: : struct bit
: : {        int a:3;
: :          int b:2;
: :          int c:3;
: : };
: : int main(int argc, char* argv[])
: : {        bit s;
: :          char *c = (char*)&s;
: :          *c = 0x99;
: :          cout << s.a <<endl <<s.b<<endl<<s.c<<endl;
: :          return 0;
: : }
: : Output:

●intel的宏定义的题目
struct S{
   int field_1;
   int field_2;
}
void main()
{
    printf("%d:%d",offset(field_1,struct S),offset(field_2,struct S));
}
让你把offset的宏定义写出来
威盛笔试硬件前端
1.一个模拟和数字的混合电路,问布线错误的地方
2.设计一个FIFO的满空信号,读写时钟频率相同,相位不同
3.用Verilog或VHDL写同步和异步复位的DFF
4.2002的16进制
5.画出PCI系统框图
6.写一个什么测试向量
7.两种有限状态机,并画电路
8.写一个英文信
还有3个忘记了

东信笔试题目
笔试:30分钟。
1 压控振荡器的英文缩写
2 动态随机存储器的英文缩写
3 选择电阻时要考虑什么
4 单片机上电后没有运转,首先要检查什么
5 计算机的基本组成部分及其各自的作用
6 用D触发器、与或非门组成二分频电路
专业英语题:1、一篇关于Hacker的文章阅读理解,选择题
              (另外的卷子是讲mobile的辐射的)
            2、智能网业务的中译英
还有一道问答题:通信行业是否与其他行业大不相同?是否需要特殊的管理方式?
威盛软件面试题目
1. char * str1="hello";
   char * str2="hello";
   *str1='p';
   cout<<str2<<str1<<endl;
问执行结果
2. char * str="hello, world!"
    strcpy(str,"hi");
大概是这样,问执行结果
3. RET和RETI两个汇编返回的区别
4. VC中程序编译成汇编后,开头结尾都有固定的两个语句 ,问是什么。

威盛的logic考试
1.用英文写你最近完成了什么样的问题?
3.Z=S?A:B,用cmos电路搭建
4.两位的全加法器的真值表和逻辑电路设计。
5.Verilog的非阻塞赋值问题。
   clk,a=4h'0,b=4h'8,
always@(posedge clk) a=b+1;
always@(posedge clk) a=b+1;
画出a,b得时序图
6.自动售货机。只卖0.35美元的东东,可投0.25, 0.1, 0.05美元,
自设变量,画出状态机图。
还有一些名词解释,一道智力题。
威盛的考题(转自水木)
Software的题
第一题
把x86的数据流图画出来,包括cpu,mem,chipset(south bridge and north..)
io sub-system, AGP, io bus, etc
第二题
(1)说明write back/ write through 的区别,这个好像是关于cache的两种策略吧
我只有关于os的延迟写回等概念,所以这个我不知道
(2)内存读取时间1000ns、cache读取时间100ns,读命中的概率0.9
对cache修改的可能性20%,只读的可能性80%,大致是这么个意思
要你求平均的读时间
第三题
c语言的题
最关键的地方是这样一句话
sprintf(s, "%%.%is\n", 5);
printf(s, "hello, world!");
我不知道%i是不是和%d用法一样
如果是的话,%.5s在字符串里面不知道表示什么意思,有%2.3f之类的,没有听说过%.5
s
第四题
汇编的题
需要掌握的就是x86下面的各个寄存器做什么用处的
题目要求吧这个汇编转成c语言描述
中间有个call语句,之前push,之后pop,此外用到mul运算
第五题
第六题
都是arm的题
第五是选择题,说arm有哪些特点
中间的题,我都没有仔细看了
应该还有两到三道
最后一道题
是说明什么是奈奎斯特定理。
由于是英语的题,而且我对信号处理不熟悉
感觉是奈奎斯特,不知道错没有错,如果没有错的话,别的书上翻译做香农定理吧
开始我选的是logic,看了两眼后,发现有一半不会
就想还是做software吧,毕竟是搞算法的,做的程序也不少了
于是就换了software的题,结果更惨,就会2、3道题
题如下:
最后一道题是逻辑判断,有点gre的味道
中间有个题是设计个全加器,要求用与或非等门,要求写出全过程
我旁边的一个哥们偷偷的问我,卡诺图怎么弄来着,我郁闷的说大概是00, 01, 11, 10
这么个顺序吧
对了,还有个verilog的题,语言很简单,像我这样只会vhdl的也能看懂 : -)
东信笔试题目
笔试:30分钟。
1 压控振荡器的英文缩写
2 动态随机存储器的英文缩写
3 选择电阻时要考虑什么
4 单片机上电后没有运转,首先要检查什么
5 计算机的基本组成部分及其各自的作用
6 用D触发器、与或非门组成二分频电路
专业英语题:1、一篇关于Hacker的文章阅读理解,选择题
              (另外的卷子是讲mobile的辐射的)
            2、智能网业务的中译英
还有一道问答题:通信行业是否与其他行业大不相同?是否需要特殊的管理方式?
我的是中文回答,还有别的卷子是英文回答。
记得的就这些了。大家补充。反正我是歇菜了。
1、自我介绍
2、你做过什么,遇到什么问题,怎么解决    
3、你的工作兴趣是什么
4、你对东信有什么看法,有什么需要了解的?
5、如果没问题,你可以走了。
via 的8道题
1, 三组程序,找出错误,如果有的话.
    1> a.c    long    temp[255];
         b.c     extern *temp;
    2>a.c     long    temp[255];
         b.c    extern    temp[256];
    3>a.c     long    temp[255];
         b.c    extern    temp[];
2, 在第一个声明处编译出了奇怪的错误,为什么?
    #include <stdio.h>
    #include "myfun1.h"
    #include "myfun2.h"
    int myInt1;
int myInt2;
3, printf("0x%x", (&0)[-1]); 请问打印了什么?
4, #define offset(s,c) 同intel的题.
5, 汇编,用ax,bx,cx,dx, 求1000*1000/30(四舍五入), 结果放在ax中.
6, 编最优化Bubble(int *pIntArray,int L),要求:交换元素不能用临时变量,如果有序,需
要最优.
7,      1,2,3,4,5,6,7,8,9从栈里出来的可能性. (略)
8,     求一个struct的sizeof.(略)
这两题没太大难度.
招聘考题(一)
TC2.0 环境下的如下程序, 执行结果为
please input: scanf : floating point formats not linked
Abnormal program termination
试解决!
#include "stdio.h"
#include "stdlib.h"
main()
{
float *a;
a = (float *)malloc(10*sizeof(float));
printf("
Please input: ");
scanf("%f", &a[0]); /* &a[0] 也不行 */
printf("
What you have input is %f
", *a);
getch();
free(a);
}

re:招聘考题一道           
tc2.0中用scanf输入数组的值不能使用浮点型。
只要一用就会出现题目中的错误。
据说这是一个没有解决的BUG。
要解决这个问题可以使用一个变量充当“中间人”传送数据。
其实方法很多的。

微软试题
微软,软件业的巨人,是每个的特别是年轻软件开发人的梦想之地,微软的面试是非常严格的,录取比例大约是60有中选一人,相信可爱的梦想家们肯定急切的想知道怎么样才能幸运的成为1/60!
   微软面试试题可分为(1)迷语,(2)算法,(3)应用程序,(4)智力等等,
本文为迷语篇
  现取部分试题内容:
  1.为什么下水道的盖子是圆的?
  2.美国有多少辆汽车?
  3.你让工人为你工作七天,回报是一根金条。这个金一平分成相连的7段,你必须在每天结束的时候给他们一段金条如果只许你两次把金条弄断,你如果给你的工人付费?
  4.有一辆火车以每小时15公里的速度离开洛杉矶直奔纽约,另一辆火车以第小时20公里的速度从纽约开往洛杉矶。如果有一只鸟,以外30公里每小时的速度和两辆火车现时启动,比洛杉叽出发,碰到另辆车后返回,依次在两辆火车来回的飞行,只到两面辆火车相遇,请问,这只小鸟习行了多长距离?
   5.你有两个罐子,50个红色弹球,50个蓝色弹球,随机选出一个罐子,随机选取出一个弹球放入罐子,怎么给红色弹球最大的选中机会?在你的计划中,得到红球的准确几率是多少?
   6.想象你在镜子前,请问,为什么镜子中的影像可以颠倒左右,却不能颠倒上下?
  7.你有四人装药丸的罐子,每个药丸都有一定的重量,被污染的药丸是没被污染的重量+1.只称量一次,如何判断哪个罐子的药被污染了?
  8.如果你有无穷多的水,一个3夸脱的和一个5夸脱的提桶,你如何准确称出4夸脱的水?
  9.你有一桶果冻,其中有黄色,绿色,红色三种,,闭上眼睛选出同样颜色的两个,抓取同种颜色的两个。抓取多少个就可以确定你肯定有两个同一颜色的果冻?
  10.将汽车钥匙插入车门,向哪个方向旋转就可以打开车锁?
11.如果要你能去掉50个州的任何一个,那你去掉哪一个,为什么?
Riddles
* Why is a manhole cover round?
* How many cars are there in the USA?
 

 

 

MSRA Interview Written Exam(December 2003,Time:2.5 Hours)

1写出下列算法的时间复杂度。
(1)冒泡排序;
(2)选择排序;
(3)插入排序;
(4)快速排序;
(5)堆排序;
(6)归并排序;

2写出下列程序在X86上的运行结果。

struct mybitfields
{
unsigned short a : 4;
unsigned short b : 5;
unsigned short c : 7;
}test

void main(void) 
 {
int i;
test.a=2;
test.b=3;
test.c=0;

i=*((short *)&test);
printf("%d\n",i);
}

3写出下列程序的运行结果。

unsigned int i=3;
cout<<i * -1;

4写出下列程序所有可能的运行结果。

int a;
int b;
int c;

void F1()
{
b=a*2;
a=b;
}

void F2()
{
c=a+1;
a=c;
}

main()
{
a=5;
//Start F1,F2 in parallel
F1(); F2();
printf("a=%d\n",a);
}

5考察了一个CharPrev()函数的作用。

6对 16 Bits colors的处理,要求:
(1)Byte转换为RGB时,保留高5、6bits;
(2)RGB转换为Byte时,第2、3位置零。

7一个链表的操作,注意代码的健壮和安全性。要求:
(1)增加一个元素;
(2)获得头元素;
(3)弹出头元素(获得值并删除)。

8一个给定的数值由左边开始升位到右边第N位,如
0010<<1 == 0100
或者
0001 0011<<4 == 0011 0000
请用C或者C++或者其他X86上能运行的程序实现。

附加题(只有在完成以上题目后,才获准回答)
In C++, what does "explicit" mean? what does "protected" mean?

 

 

微软笔试题目
 
1 立方体,每面涂上红或蓝,从n个中取出多少个会出现两个一样的立方体?
 2 1-1024号灯,从左到右交叉打开关着的灯,然后从右到左
   交叉打开关着的灯,然后又从左到右,再然后......hehe,不说了,
   问:最后打开的是几号灯?
 3 球上涂上n个点,点点间距离相等,n等于几?
 4 彩票上写上1~100中的10个数,从1~100中划去10个数,如果你
   的彩票上的十个数都在上述90个数内,就恭喜你了。问:你买多少张
   彩票肯定会中风?如何设计号码?
 

 


阿尔卡特NGN software dev.笔试题目
 

 

1、为什么电话里的声音与面对面谈话的声音不同,阐述失真原因。
 2、BHCA 与 Erl 的含义,以及两者之间的关系。
 3、全球通与神州性有什么区别;有了全球通,为什么要引入神州行。
 4、3G标准有哪些,之间有什么区别,为什么要引入3G。
 5、
 main()
 {
 int x;
 x = 25;
 printf("%d\n",x);
 }
 通过编译连接,用符号调试器进行调试,找不到x,问原因。
 6、Unix环境下,建一个属于group的用户test,用户目录位于/export/home/test.给出
 命令;为test改变密码的命令。
 7、e文描述osi七层模型,及每一层的具体功能。
 8、PDU与SDU的区别。
 9、BSSAP由BSSMAP与()构成。
 10、MAP和IS41信令都是通过SS7的MTP、SCCP和()传输。
 11、e文给出当2+1=2的三种情况。
 

 

微创2010年招聘笔试题目
 

 

一 编程
1.(35分)
 输入一个单链表,输出该链表中倒数第k个节点,链表的倒数第0个节点为链表的尾指针,
 链表结构定义:
 struct ListNode{
 int m_nKey;
 listNode* m_pNode; 
 };
用C/C++编写PrintNode函数,要求考虑链表非常大时的时间复杂度;
 PrintNode函数原型:void PrintNode(const ListNode *link,int k);
注:可以不用C/C++编写,可以用你自己熟悉的语言编写,但是首先扣掉10
另外 只写出思路或者伪代码,给5分;
2.(35分)
 对一个整数数组,给定一个整数,在数组中找到两个数,这两个数之和等于所给定的这个整数,这样的数可能有多对,要求输出所有可能的组合。
要求考虑数组非常大,时间复杂度和空间复杂度;
 二。测试(15分)
    想办法测试MSDN,尽可能考虑更多的用例,写出你的测试方案;
注:并非考试你是否学习软件测试,而是看你解决问题的思路,
 三写作(15分)
假如你现在手上有个不得不按时完成,而且所用工具是个陌生的没有时间来上手的,请你给你的pm发封英文电子邮件,请他帮你解决

 

 

微软的应试题完整版(附答案)
 

 

网上有不少Microsoft的测试题,引来不少的眼光。在这里把所有的测试题加以整理,再附上答案。(个别题目答案有多种,文本仅代表作者的思路)每道题的后面会给出一个时间。这个时间是作者做出该题所用的时间。(注意,这不是什么标准时间,相信所有浏览本试卷的朋友都会在某一道或多道题上找到灵感,迅速解题的) !
 一.最基本题型(说明:此类题型比较简单)
1.烧一根不均匀的绳,从头烧到尾总共需要1个小时。现在有若干条材质相同的绳子,问如何用烧绳的方法来计时一个小时十五分钟呢?(这道题我当初想了一个小时)
2.你有一桶果冻,其中有黄色、绿色、红色三种,闭上眼睛抓取同种颜色的两个。抓取多少个就可以确定你肯定有两个同一颜色的果冻?(5秒-1分钟)
3.如果你有无穷多的水,一个3公升的提捅,一个5公升的提捅,两只提捅形状上下都不均匀,问你如何才能准确称出4公升的水?(40秒-3分钟)
4.一个岔路口分别通向诚实国和说谎国。来了两个人,已知一个是诚实国的,另一个是说谎国的。诚实国永远说实话,说谎国永远说谎话。现在你要去说谎国,但不知道应该走哪条路,需要问这两个人。请问应该怎么问?(20秒-2分钟)
 5.12个球一个天平,现知道只有一个和其它的重量不同,问怎样称才能用三次就找到那个球。13个呢?(注意此题并未说明那个球的重量是轻是重,所以需要仔细考虑)(5分钟-1小时) _
 6.在9个点上画10条直线,要求每条直线上至少有三个点?(3分钟-20分钟)
.在一天的24小时之中,时钟的时针、分针和秒针完全重合在一起的时候有几次?都分别是什么时间?你怎样算出来的?(5分钟-15分钟)
二.没有答案型(说明:这些题显然不是考你智力。而考的是你的反应能力。这种题大多数没有答案,但是要看你的反应喽!)
1.为什么下水道的盖子是圆的?
2.中国有多少辆汽车?
3.将汽车钥匙插入车门,向哪个方向旋转就可以打开车锁?
4.如果你要去掉中国的34个省(含自治区、直辖市和港澳特区及台湾省)中的任何一个,你会去掉哪一个,为什么?
 5.多少个加油站才能满足中国的所有汽车?
6.想象你站在镜子前,请问,为什么镜子中的影象可以颠倒左右,却不能颠倒上下?
7.为什么在任何旅馆里,你打开热水,热水都会瞬间倾泻而出?
8.你怎样将Excel的用法解释给你的奶奶听?
9.你怎样重新改进和设计一个ATM银行自动取款机?
10.如果你不得不重新学习一种新的计算机语言,你打算怎样着手来开始?
如果你的生涯规划中打算在5年内受到奖励,那获取该项奖励的动机是什么?观众是谁?
如果微软告诉你,我们打算投资五百万美元来启动你的投资计划,你将开始什么样商业计划?为什么?
 13.如果你能够将全世界的电脑厂商集合在一个办公室里,然后告诉他们将被强迫做一件事,那件事将是什么?
 三.难题(说明:这类题有一定难度,如果得不到答案,也不能说明什么。如果你想到了解题思路,那么答案马上就能出来。如果想不到思路,那么……就别想解出来了。)
你让工人为你工作7天,回报是一根金条,这个金条平分成相连的7段,你必须在每天结束的时候给他们一段金条。如果只允许你两次把金条弄断,你如何给你的工人付费?
2.有一辆火车以每小时15公里的速度离开北京直奔广州,同时另一辆火车每小时20公里的速度从广州开往北京。如果有一只鸟,以30公里每小时的速度和两辆火车同时启动,从北京出发,碰到另一辆车后就向相反的方向返回去飞,就这样依次在两辆火车之间来回地飞,直到两辆火车相遇。请问,这只鸟共飞行了多长的距离? .
 3.你有四个装药丸的罐子,每个药丸都有一定的重量,被污染的药丸是没被污染的药丸的重量+1。只称量一次,如何判断哪个罐子的药被污染了? 
 4.门外三个开关分别对应室内三盏灯,线路良好,在门外控制开关时候不能看到室内灯的情况,现在只允许进门一次,确定开关和灯的对应关系?
5.人民币为什么只有1、2、5、10的面值?
6.你有两个罐子以及50个红色弹球和50个蓝色弹球,随机选出一个罐子, 随机选出一个弹球放入罐子,怎么给出红色弹球最大的选中机会?在你的计划里,得到红球的几率是多少?
 u四.超难题(说明:如果你是第一次看到这种题,并且以前从来没有见过类似的题型,并且能够在半个小时之内做出答案。只能说明你的智力超常……)
第一题 . 五个海盗抢到了100颗宝石,每一颗都一样大小和价值连城。他们决定这么分:
抽签决定自己的号码(1、2、3、4、5)
首先,由1号提出分配方案,然后大家表决,当且仅当超过半数的人同意时,按照他的方案进行分配,否则将被扔进大海喂鲨鱼
如果1号死后,再由2号提出分配方案,然后剩下的4人进行表决,当且仅当超过半数的人同意时,按照他的方案进行分配,否则将被扔入大海喂鲨鱼
^依此类推
条件:每个海盗都是很聪明的人,都能很理智地做出判断,从而做出选择。
问题:第一个海盗提出怎样的分配方案才能使自己的收益最大化?
第二题 . 一道关于飞机加油的问题,已知:
 每个飞机只有一个油箱, '
 飞机之间可以相互加油(注意是相互,没有加油机)
一箱油可供一架飞机绕地球飞半圈,
 问题:
为使至少一架飞机绕地球一圈回到起飞时的飞机场,至少需要出动几架飞机?(所有飞机从同一机场起飞,而且必须安全返回机场,不允许中途降落,中间没有飞机场) 
 五.主观题(说明:在以后的工作过程中,我们可定会犯这样那样的错误。既然错误已经酿成,损失在所难免,我们只能想办法把损失减少到最小。如果能巧妙地回答出这些问题,再发生错误的情况下。能让客户有最少的抱怨,公司有最少的损失。)
 1.某手机厂家由于设计失误,有可能造成电池寿命比原来设计的寿命短一半(不是冲放电时间),解决方案就是免费更换电池或给50元购买该厂家新手机的折换券。请给所有已购买的用户写信告诉解决方案。
 "2.一高层领导在参观某博物馆时,向博物馆馆员小王要了一块明代的城砖作为纪念,按国家规定,任何人不得将博物馆收藏品变为私有。博物馆馆长需要如何写信给这位领导,将城砖取回。
 3.营业员小姐由于工作失误,将2万元的笔记本电脑以1.2万元错卖给李先生,王小姐的经理怎么写信给李先生试图将钱要回来?
六.算法题(说明:这些题就不是什么花样了,考的是你的基础知识怎么样。再聪明而没有实学的人都将会被这些题所淘汰。)
1.链表和数组的区别在哪里?
2.编写实现链表排序的一种算法。说明为什么你会选择用这样的方法?
3.编写实现数组排序的一种算法。说明为什么你会选择用这样的方法?
4.请编写能直接实现strstr()函数功能的代码。
5.编写反转字符串的程序,要求优化速度、优化空间。
6.在链表里如何发现循环链接? .
 7.给出洗牌的一个算法,并将洗好的牌存储在一个整形数组里。
 8.写一个函数,检查字符是否是整数,如果是,返回其整数值。(或者:怎样只用4行代码编写出一个从字符串到长整形的函数?)
9.给出一个函数来输出一个字符串的所有排列。
.请编写实现malloc()内存分配函数功能一样的代码。
给出一个函数来复制两个字符串A和B。字符串A的后几个字节和字符串B的前几个字节重叠。
12.怎样编写一个程序,把一个有序整数数组放到二叉树中?
13.怎样从顶部开始逐层打印二叉树结点数据?请编程。  
14.怎样把一个链表掉个顺序(也就是反序,注意链表的边界条件并考虑空链表)?
 答案
 [解答与提示] 一.最基本题型
1.一要一头烧,一根从两头烧,再有一根做参照,两头烧完的记下位置(即烧到这里要半小时),把参照的那根从标记位置处剪开,取其中一段A。
一头烧的那根烧完后(就是一个小时后),把A从两头开始烧,烧完后即为十五分钟,加起来共一小时十五分钟。
 2.4个。
3.大桶装满水,倒入小桶,大桶剩下2公升水。小桶水倒掉,大桶剩2公升水倒入小桶中,大桶再装满后,倒入小桶至小桶满,大桶即剩4公升
4.如果参加过类似于奥林匹克数学班的,都应做过这些题。问他你的国家怎么走,他肯定指向的是诚实国。
5.12个时可以找出那个是重还是轻,13个时只能找出是哪个球,轻重不知。
把球编为①②③④⑤⑥⑦⑧⑨⑩⑾⑿。(13个时编号为⒀)
第一次称:先把①②③④与⑤⑥⑦⑧放天平两边,
  ㈠如相等,说明特别球在剩下4个球中。
    把①⑨与⑩⑾作第二次称量,
    ⒈如相等,说明⑿特别,把①与⑿作第三次称量即可判断是⑿是重还是轻
    ⒉如①⑨<⑩⑾说明要么是⑩⑾中有一个重的,要么⑨是轻的。
     把⑩与⑾作第三次称量,如相等说明⑨轻,不等可找出谁是重球。
    ⒊如①⑨>⑩⑾说明要么是⑩⑾中有一个轻的,要么⑨是重的。
      把⑩与⑾作第三次称量,如相等说明⑨重,不等可找出谁是轻球。
  ㈡如左边<右边,说明左边有轻的或右边有重的
   把①②⑤与③④⑥做第二次称量 '
    ⒈如相等,说明⑦⑧中有一个重,把①与⑦作第三次称量即可判断是⑦与⑧中谁是重球 
     ⒉如①②⑤<③④⑥说明要么是①②中有一个轻的,要么⑥是重的。
     把①与②作第三次称量,如相等说明⑥重,不等可找出谁是轻球。 
     ⒊如①②⑤>③④⑥说明要么是⑤是轻的,要么③④中有一个是重的。 .
       把③与④作第三次称量,如相等说明⑤轻,不等可找出谁是重球。
  ㈢如左边>右边,参照㈡相反进行。
当13个球时,第㈠步以后如下进行。
  把①⑨与⑩⑾作第二次称量,
 ⒈如相等,说明⑿⒀特别,把①与⑿作第三次称量即可判断是⑿还是⒀特别,但判断不了轻重了。
 ⒉不等的情况参见第㈠步的⒉⒊
6. 见下面的点 10条线的情况是 123 456 789 148 159 247 258 269 357 368
① ② ③
 ④⑤⑥
⑦ ⑧ ⑨
注意是24小时不是12小时。
首先考察时针与分针的情况,很容易看出分针转一圈与时针只重合一次,就是一小时一次。但11时与0时的分钟区内共享一个重合点,所只
 二.没有答案型
1.圆井盖掉不下去
2.一千万
3.顺时针方向。
4.
5.十万个
6.答案是"This feature is by design." 如果考官要求给出更加合理的解释,就对他说:"如果您对此问题有更多疑问,请与它的供应商(或者与它的发明人)联系"。 答案是眼睛是左右长着的。 
 7.如果不倾泻而出,这家旅馆将没有人去住。
 8.告诉她这是最先进的东西,她不需要动手,我来帮她做就可以。
9.我想斯皮尔伯格来回答这道题是在合适不过得了。
10.我觉得回放飞网呆上半个月比较合适。 '
 11.这题我没有任何想法,因为没有工作经验,所以完全没听明白他问的是什么!
12.做微软的OEM,这样能够更好的服务微软。
13.把主机箱集成在一个液晶显示器中! 只准开发我们认证的驱动!
 三.难题
1.切两刀,分为1/7、2/7、4/7三段。第一天给1/7;第二天给2/7,要回1/7;第三天给1/7 ;第四天给4/7 要回1/7+2/7;第五天给1/7;第六天给2/7,要会1/7;第七天给1/7
 2.北京到广州距离的30/35。
3.依次从四个罐子中取出1、2、3、4个药丸,设第一丸子应重为X,称得的重量是10X+t,t是几就是第几个罐子污染了。
 4.先开一个,开很长时间。然后关掉,再开另一个。出去看,亮着的那个不用说。剩下的两个不亮的,按照灯泡的温度来进行判断。
5.可以用三张以内组成任何面额。
 6.不清楚。可能是50%。
四.超难题
设5个人分别是①②③④⑤
假设前面的都扔海里了,由④来分,无论他怎么分(包括全给⑤),都面临被否决扔海里的危险。
所以,当③来分时,④⑤一个不给,全由③独吞,④为了避免被扔海里的危险,也要同意,③的方案成立
 那么,在②分时,③是肯定要反对的,要赢得④⑤的同意,必须多给一个,否则有可能否决(对④⑤来说,反正③来分时还是0,你不多给一个就否决),所以②的分配方案一定是:②98 ③0 ④1 ⑤1 # A.
 回到①来的分配,由于②肯定反对,为了赢得③④⑤的同意,必须在②分配方案的基础上给他们加一个,由于只需再争取两票,③④⑤中可以
排除争取一个,从收益来说,排除④⑤中的一个即可,那么①的分配方案为:①97 ③1 ④(或⑤)1 其它都不给!
二) 如果机场本身不可以加油的话 那么最少需要4架
3架同时起飞,到1/6圈时,两架飞机把各自油箱中的1/3加给另外一架,这两架剩的油正好可以原路飞回,被加油机可以飞到5/6圈处。
第4架飞机在环球飞机飞到4/6圈时起飞去接应,两飞机在5/6圈处相遇,环球机刚好用完油,加油机把1/3的油给环球机,两飞机刚好都能飞回

五.主观题
1.告诉用户我公司为答谢广大顾客长时间以来的厚爱,顾客可以持原电池免费更换使用寿命为原电池一倍的新型电池。或者可以持购买发票,获得50元购买该厂家新手机的折换券。
 2.信件如下:
"xxx领导:您好!
 我馆近期将展出一批珍贵文物,让更多的人能够真正的体会到中华民族文明的悠久、灿烂。我们希望能将您所拥有的明代的城砖展出。并且我们将在博物馆内设置专栏,宣传您对中华民族悠久文化的保存所作出的巨大贡献,让更多的华夏子孙看到,并且亲身体验到华夏文明的悠久历史,从而加强中华民族的凝聚力!"
 !解释:
领导看过这封信以后,如果不拿出城砖。那么也就说明他不想让更多的人看到中华民族的灿烂文明,不想让中华民族有更强的凝聚力。自然也就会拿出城砖。如果领导问到何时展出完毕,可以告诉他博物馆希望永久展出这些物品,领导自然也就无话可说了。
 3.信件如下:
3  尊敬的顾客,您好!
由于工作人员的失误,误将一台样品机卖给您。为了您能够更好的使用我公司的产品,我公司决定为您免费更换同等价位的笔记本一台。并且我们有性价比更加优越的xxxII 型笔记本电脑,售价20000元人民币。如果您此时购买,我们将会以19000元的优惠价格售出。"
 
六.算法题
请参考数据结构和计算机算法类书籍,作者就不再抄书了。
附(1):烧绳子类问题总结:
 一般给出的绳子都是不均匀的。如果一根为一小时,那么半个小时的计算方法是从两头烧。十五分钟的计算方法是从两头烧,同时从中间任何一个地方开始烧,这样这根绳子就有四个燃烧点,时间自然是一个燃烧点的四分之一。如果计算十分钟的时间,那么就让绳子有六个燃烧点,方法就不用说了吧!
 附(2):天平称球问题解答以及总结:
将球分为a b c d; e f g h; i j k l 三组。
第一次称量,比较 abcd efgh
情形一:
两者重量相等,此时说明答案在ijkl中。
 称量ij,
 如果相等,说明答案在kl中。拿k与a比较,如果相等,答案为l;如果不等,答案为k。 '
如果不等,说明答案在ij中。拿i与a比较,如果相等,答案为j;如果不等,答案为i。
 
情形二:
abcd轻。
在efgh中取出fgh,替换掉abcd中的bcd。 在ijkl中取出jkl,补充到原来fgh的位置。
_如果afgh轻,说明答案为a或e。称量ab,如果相等,答案为e;如果不等,答案为a。
如果afgh重,说明答案在fgh中。称量fg,如果相等,答案为h;如果不等,重者为答案。
如果一样重,答案在bcd中。称量bc,如果相等,答案为d;如果不等,轻者为答案。
情形三:
abcd重。
在efgh中取出fgh,替换掉abcd中的bcd。 在ijkl中取出jkl,补充到原来fgh的位置。
如果afgh重,答案为a或e。称量ab,如果相等,答案为e;如果不等,答案为a。 ^
 如果afgh轻,答案在fgh中。称量fg,如果相等,答案为h;如果不等,轻者为所求。
如果一样重,答案在bcd中。称量bc,如果相等,答案为d;如果不等,重者为答案。
至于13个球的称法,至今本人仍没想出来。望高手赐教。
总结:(转载)
天平称重,有两个托盘比较轻重,加上托盘外面,也就是每次称重有3个结果,就是ln3/ln2比特信息。n个球要知道其中一个不同的球,如果知道那个不同重量的球是轻还是重,找出来的话那就是n个结果中的一种,就是有ln(n)/ln2比特信息,如果不知道轻重,找出来就是2n(n个球中的一个,轻或者重,所以是2n)个结果中的一种,那就是ln(2n)/ln2比特信息。
 假设我们要称k次,根据信息理论,那显然两种情况就分别有:
1. k*ln3/ln2>=ln(n)/ln2 (k>=1) 解得k>=ln(n)/ln3
2. k*ln3/ln2>=ln(2n)/ln2 (k>1) 解得k>=ln(2n)/ln3
这是得到下限,可以很轻易证明满足条件的最小正整数k就是所求。比如称3次知道轻重可以从3^3=27个球中找出不同的球出来,如果不知道轻重就只能从(3^3-1)/2=13个球中找出不同的球出来。 
 

 

101道微软IT笔试题
 

 


Algorithms and Programming
 1. Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ?
 2. You’re given an array containing both positive and negative integers and required to find the sub-array with the largest sum (O(N) a la KBL). Write a routine in C for the above.
 3. Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].
 4. Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all. [ This one had me stuck for quite some time and I first gave a solution that did have floating point computations ].
 5. Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
 6. Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
 7. Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
 8. How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started.
 9. Give a very good method to count the number of ones in a “n” (e.g. 32) bit number.
 ANS. Given below are simple solutions, find a solution that does it in log (n) steps.
 Iterative
 function iterativecount (unsigned int n)
 begin
 int count=0;
 while (n)
 begin
 count += n & 0×1 ;
 n >>= 1;
 end
 return count;
 end
 Sparse Count
 function sparsecount (unsigned int n)
 begin
 int count=0;
 while (n)
 begin
 count++;
 n &= (n-1);
 end
 return count ;
 end
 10. What are the different ways to implement a condition where the value of x can be either a 0 or a 1. Apparently the if then else solution has a jump when written out in assembly. if (x == 0) y=a else y=b There is a logical, arithmetic and a data structure solution to the above problem.
 11. Reverse a linked list.
 12. Insert in a sorted list
 13. In a X’s and 0’s game (i.e. TIC TAC TOE) if you write a program for this give a fast way to generate the moves by the computer. I mean this should be the fastest way possible.
 The answer is that you need to store all possible configurations of the board and the move that is associated with that. Then it boils down to just accessing the right element and getting the corresponding move for it. Do some analysis and do some more optimization in storage since otherwise it becomes infeasible to get the required storage in a DOS machine.
 14. I was given two lines of assembly code which found the absolute value of a number stored in two’s complement form. I had to recognize what the code was doing. Pretty simple if you know some assembly and some fundaes on number representation.
 15. Give a fast way to multiply a number by 7.
 16. How would go about finding out where to find a book in a library. (You don’t know how exactly the books are organized beforehand).
 17. Linked list manipulation.
 18. Tradeoff between time spent in testing a product and getting into the market first.
 19. What to test for given that there isn’t enough time to test everything you want to.
 20. First some definitions for this problem: a) An ASCII character is one byte long and the most significant bit in the byte is always ‘0′. b) A Kanji character is two bytes long. The only characteristic of a Kanji character is that in its first byte the most significant bit is ‘1′.
 Now you are given an array of a characters (both ASCII and Kanji) and, an index into the array. The index points to the start of some character. Now you need to write a function to do a backspace (i.e. delete the character before the given index).
 21. Delete an element from a doubly linked list.
 22. Write a function to find the depth of a binary tree.
 23. Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
 24. Assuming that locks are the only reason due to which deadlocks can occur in a system. What would be a foolproof method of avoiding deadlocks in the system.
 25. Reverse a linked list.
 Ans: Possible answers -
 iterative loop
 curr->next = prev;
 prev = curr;
 curr = next;
 next = curr->next
 endloop
 recursive reverse(ptr)
 if (ptr->next == NULL)
 return ptr;
 temp = reverse(ptr->next);
 temp->next = ptr;
 return ptr;
 end
 26. Write a small lexical analyzer - interviewer gave tokens. expressions like “a*b” etc.
 27. Besides communication cost, what is the other source of inefficiency in RPC? (answer : context switches, excessive buffer copying). How can you optimize the communication? (ans : communicate through shared memory on same machine, bypassing the kernel _ A Univ. of Wash. thesis)
 28. Write a routine that prints out a 2-D array in spiral order!
 29. How is the readers-writers problem solved? - using semaphores/ada .. etc.
 30. Ways of optimizing symbol table storage in compilers.
 31. A walk-through through the symbol table functions, lookup() implementation etc. - The interviewer was on the Microsoft C team.
 32. A version of the “There are three persons X Y Z, one of which always lies”.. etc..
 33. There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner.. what is the probability that they don’t collide.
 34. Write an efficient algorithm and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
 35. The if (x == 0) y = 0 etc..
 36. Some more bitwise optimization at assembly level
 37. Some general questions on Lex, Yacc etc.
 38. Given an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).
 39. Given an array of characters. How would you reverse it. ? How would you reverse it without using indexing in the array.
 40. Given a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - solutions given in the C lib -typec.h)
 41. Fundamentals of RPC.
 42. Given a linked list which is sorted. How will u insert in sorted way.
 43. Given a linked list How will you reverse it.
 44. Give a good data structure for having n queues ( n not fixed) in a finite memory segment. You can have some data-structure separate for each queue. Try to use at least 90% of the memory space.
 45. Do a breadth first traversal of a tree.
 46. Write code for reversing a linked list.
 47. Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
 48. Given an array of integers, find the contiguous sub-array with the largest sum.
 ANS. Can be done in O(n) time and O(1) extra space. Scan array from 1 to n. Remember the best sub-array seen so far and the best sub-array ending in i.
 49. Given an array of length N containing integers between 1 and N, determine if it contains any duplicates.
 ANS. [Is there an O(n) time solution that uses only O(1) extra space and does not destroy the original array?]
 50. Sort an array of size n containing integers between 1 and K, given a temporary scratch integer array of size K.
 ANS. Compute cumulative counts of integers in the auxiliary array. Now scan the original array, rotating cycles! [Can someone word this more nicely?]
 * 51. An array of size k contains integers between 1 and n. You are given an additional scratch array of size n. Compress the original array by removing duplicates in it. What if k << n?
 ANS. Can be done in O(k) time i.e. without initializing the auxiliary array!
 52. An array of integers. The sum of the array is known not to overflow an integer. Compute the sum. What if we know that integers are in 2’s complement form?
 ANS. If numbers are in 2’s complement, an ordinary looking loop like for(i=total=0;i< n;total+=array[i++]); will do. No need to check for overflows!
 53. An array of characters. Reverse the order of words in it.
 ANS. Write a routine to reverse a character array. Now call it for the given array and for each word in it.
 * 54. An array of integers of size n. Generate a random permutation of the array, given a function rand_n() that returns an integer between 1 and n, both inclusive, with equal probability. What is the expected time of your algorithm?
 ANS. “Expected time” should ring a bell. To compute a random permutation, use the standard algorithm of scanning array from n downto 1, swapping i-th element with a uniformly random element <= i-th. To compute a uniformly random integer between 1 and k (k < n), call rand_n() repeatedly until it returns a value in the desired range.
 55. An array of pointers to (very long) strings. Find pointers to the (lexicographically) smallest and largest strings.
 ANS. Scan array in pairs. Remember largest-so-far and smallest-so-far. Compare the larger of the two strings in the current pair with largest-so-far to update it. And the smaller of the current pair with the smallest-so-far to update it. For a total of <= 3n/2 strcmp() calls. That’s also the lower bound.
 56. Write a program to remove duplicates from a sorted array.
 ANS. int remove_duplicates(int * p, int size)
 {
 int current, insert = 1;
 for (current=1; current < size; current++)
 if (p[current] != p[insert-1])
 {
 p[insert] = p[current];
 current++;
 insert++;
 } else
 current++;
 return insert;
 }
 57. C++ ( what is virtual function ? what happens if an error occurs in constructor or destructor. Discussion on error handling, templates, unique features of C++. What is different in C++, ( compare with unix).
 58. Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list).
 59. Given 3 lines of assembly code : find it is doing. IT was to find absolute value.
 60. If you are on a boat and you throw out a suitcase, Will the level of water increase.
 61. Print an integer using only putchar. Try doing it without using extra storage.
 62. Write C code for (a) deleting an element from a linked list (b) traversing a linked list
 63. What are various problems unique to distributed databases
 64. Declare a void pointer ANS. void *ptr;
 65. Make the pointer aligned to a 4 byte boundary in a efficient manner ANS. Assign the pointer to a long number and the number with 11…1100 add 4 to the number
 66. What is a far pointer (in DOS)
 67. What is a balanced tree
 68. Given a linked list with the following property node2 is left child of node1, if node2 < node1 else, it is the right child.
 O P
 |
 |
 O A
 |
 |
 O B
 |
 |
 O C
 How do you convert the above linked list to the form without disturbing the property. Write C code for that.
 O P
 |
 |
 O B
 / \
 / \
 / \
 O ? O ?
 determine where do A and C go
 69. Describe the file system layout in the UNIX OS
 ANS. describe boot block, super block, inodes and data layout
 70. In UNIX, are the files allocated contiguous blocks of data
 ANS. no, they might be fragmented
 How is the fragmented data kept track of
 ANS. Describe the direct blocks and indirect blocks in UNIX file system
 71. Write an efficient C code for ‘tr’ program. ‘tr’ has two command line arguments. They both are strings of same length. tr reads an input file, replaces each character in the first string with the corresponding character in the second string. eg. ‘tr abc xyz’ replaces all ‘a’s by ‘x’s, ‘b’s by ‘y’s and so on. ANS.
 a) have an array of length 26.
 put ‘x’ in array element corr to ‘a’
 put ‘y’ in array element corr to ‘b’
 put ‘z’ in array element corr to ‘c’
 put ‘d’ in array element corr to ‘d’
 put ‘e’ in array element corr to ‘e’
 and so on.
 the code
 while (!eof)
 {
 c = getc();
 putc(array[c - 'a']);
 }
 72. what is disk interleaving
 73. why is disk interleaving adopted
 74. given a new disk, how do you determine which interleaving is the best a) give 1000 read operations with each kind of interleaving determine the best interleaving from the statistics
 75. draw the graph with performance on one axis and ‘n’ on another, where ‘n’ in the ‘n’ in n-way disk interleaving. (a tricky question, should be answered carefully)
 76. I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.
 77. A real life problem - A square picture is cut into 16 squares and they are shuffled. Write a program to rearrange the 16 squares to get the original big square.
 78.
 int *a;
 char *c;
 *(a) = 20;
 *c = *a;
 printf(”%c”,*c);
 what is the output?
 79. Write a program to find whether a given m/c is big-endian or little-endian!
 80. What is a volatile variable?
 81. What is the scope of a static function in C ?
 82. What is the difference between “malloc” and “calloc”?
 83. struct n { int data; struct n* next}node;
 node *c,*t;
 c->data = 10;
 t->next = null;
 *c = *t;
 what is the effect of the last statement?
 84. If you’re familiar with the ? operator x ? y : z
 you want to implement that in a function: int cond(int x, int y, int z); using only ~, !, ^, &, +, |, <<, >> no if statements, or loops or anything else, just those operators, and the function should correctly return y or z based on the value of x. You may use constants, but only 8 bit constants. You can cast all you want. You’re not supposed to use extra variables, but in the end, it won’t really matter, using vars just makes things cleaner. You should be able to reduce your solution to a single line in the end though that requires no extra vars.
 85. You have an abstract computer, so just forget everything you know about computers, this one only does what I’m about to tell you it does. You can use as many variables as you need, there are no negative numbers, all numbers are integers. You do not know the size of the integers, they could be infinitely large, so you can’t count on truncating at any point. There are NO comparisons allowed, no if statements or anything like that. There are only four operations you can do on a variable.
 1) You can set a variable to 0.
 2) You can set a variable = another variable.
 3) You can increment a variable (only by 1), and it’s a post increment.
 4) You can loop. So, if you were to say loop(v1) and v1 = 10, your loop would execute 10 times, but the value in v1 wouldn’t change so the first line in the loop can change value of v1 without changing the number of times you loop.
 You need to do 3 things.
 1) Write a function that decrements by 1.
 2) Write a function that subtracts one variable from another.
 3) Write a function that divides one variable by another.
 4) See if you can implement all 3 using at most 4 variables. Meaning, you’re not making function calls now, you’re making macros. And at most you can have 4 variables. The restriction really only applies to divide, the other 2 are easy to do with 4 vars or less. Division on the other hand is dependent on the other 2 functions, so, if subtract requires 3 variables, then divide only has 1 variable left unchanged after a call to subtract. Basically, just make your function calls to decrement and subtract so you pass your vars in by reference, and you can’t declare any new variables in a function, what you pass in is all it gets.
 Linked lists
 * 86. Under what circumstances can one delete an element from a singly linked list in constant time?
 ANS. If the list is circular and there are no references to the nodes in the list from anywhere else! Just copy the contents of the next node and delete the next node. If the list is not circular, we can delete any but the last node using this idea. In that case, mark the last node as dummy!
 * 87. Given a singly linked list, determine whether it contains a loop or not.
 ANS. (a) Start reversing the list. If you reach the head, gotcha! there is a loop!
 But this changes the list. So, reverse the list again.
 (b) Maintain two pointers, initially pointing to the head. Advance one of them one node at a time. And the other one, two nodes at a time. If the latter overtakes the former at any time, there is a loop!
 p1 = p2 = head;
 do {
 p1 = p1->next;
 p2 = p2->next->next;
 } while (p1 != p2);
 88. Given a singly linked list, print out its contents in reverse order. Can you do it without using any extra space?
 ANS. Start reversing the list. Do this again, printing the contents.
 89. Given a binary tree with nodes, print out the values in pre-order/in-order/post-order without using any extra space.
 90. Reverse a singly linked list recursively. The function prototype is node * reverse (node *) ;
 ANS.
 node * reverse (node * n)
 {
 node * m ;
 if (! (n && n -> next))
 return n ;
 m = reverse (n -> next) ;
 n -> next -> next = n ;
 n -> next = NULL ;
 return m ;
 }
 91. Given a singly linked list, find the middle of the list.
 HINT. Use the single and double pointer jumping. Maintain two pointers, initially pointing to the head. Advance one of them one node at a time. And the other one, two nodes at a time. When the double reaches the end, the single is in the middle. This is not asymptotically faster but seems to take less steps than going through the list twice.
 Bit-manipulation
 92. Reverse the bits of an unsigned integer.
 ANS.
 #define reverse(x) \
 (x=x>>16|(0×0000ffff&x)<<16, \
 x=(0xff00ff00&x)>>8|(0×00ff00ff&x)<<8, \
 x=(0xf0f0f0f0&x)>>4|(0×0f0f0f0f&x)<<4, \
 x=(0xcccccccc&x)>>2|(0×33333333&x)<<2, \
 x=(0xaaaaaaaa&x)>>1|(0×55555555&x)<<1)
 * 93. Compute the number of ones in an unsigned integer.
 ANS.
 #define count_ones(x) \
 (x=(0xaaaaaaaa&x)>>1+(0×55555555&x), \
 x=(0xcccccccc&x)>>2+(0×33333333&x), \
 x=(0xf0f0f0f0&x)>>4+(0×0f0f0f0f&x), \
 x=(0xff00ff00&x)>>8+(0×00ff00ff&x), \
 x=x>>16+(0×0000ffff&x))
 94. Compute the discrete log of an unsigned integer.
 ANS.
 #define discrete_log(h) \
 (h=(h>>1)|(h>>2), \
 h|=(h>>2), \
 h|=(h>>4), \
 h|=(h>>8), \
 h|=(h>>16), \
 h=(0xaaaaaaaa&h)>>1+(0×55555555&h), \
 h=(0xcccccccc&h)>>2+(0×33333333&h), \
 h=(0xf0f0f0f0&h)>>4+(0×0f0f0f0f&h), \
 h=(0xff00ff00&h)>>8+(0×00ff00ff&h), \
 h=(h>>16)+(0×0000ffff&h))
 If I understand it right, log2(2) =1, log2(3)=1, log2(4)=2….. But this macro does not work out log2(0) which does not exist! How do you think it should be handled?
 * 95. How do we test most simply if an unsigned integer is a power of two?
 ANS. #define power_of_two(x) \ ((x)&&(~(x&(x-1))))
 96. Set the highest significant bit of an unsigned integer to zero.
 ANS. (from Denis Zabavchik) Set the highest significant bit of an unsigned integer to zero
 #define zero_most_significant(h) \
 (h&=(h>>1)|(h>>2), \
 h|=(h>>2), \
 h|=(h>>4), \
 h|=(h>>8), \
 h|=(h>>16))
 97. Let f(k) = y where k is the y-th number in the increasing sequence of non-negative integers with the same number of ones in its binary representation as y, e.g. f(0) = 1, f(1) = 1, f(2) = 2, f(3) = 1, f(4) = 3, f(5) = 2, f(6) = 3 and so on. Given k >= 0, compute f(k).
 Others
 98. A character set has 1 and 2 byte characters. One byte characters have 0 as the first bit. You just keep accumulating the characters in a buffer. Suppose at some point the user types a backspace, how can you remove the character efficiently. (Note: You cant store the last character typed because the user can type in arbitrarily many backspaces)
 99. What is the simples way to check if the sum of two unsigned integers has resulted in an overflow.
 100. How do you represent an n-ary tree? Write a program to print the nodes of such a tree in breadth first order.
 101. Write the ‘tr’ program of UNIX. Invoked as
 tr -str1 -str2. It reads stdin and prints it out to stdout, replacing every occurance of str1 with str2.
 e.g. tr -abc -xyz
 to be and not to be <- input
 to ye xnd not to ye <- output
 

 


百度公司的笔试题目等
 

 

百度公司的笔试题目等
 姓名 __________________ 毕业院校 _________________ 专业 _____________
 
毕业时间 _____________ 手机 __________________ Email __________________
 
申请职位(请打钩,可多选):产品设计工程师 产品策略分析员

欢迎你应聘百度商业应用产品市场部!笔试时间60分钟,另提供15分钟的可选延长。请
在答题纸上作答。草稿纸另外提供。请务必通读题目后进行答题。

1. 题面:1,-6,-9,0,45,198,()

问题:请补充括号中的数字,并说明分析过程。提示,正确答案是以下数字中的某一个
:9,18,24,39,36,48,45,52,58,64,72,98

请说出推算第100个数字的方法

2. 题面:日出江花红胜火

问题:1、请补充该诗句在原诗中的下半句,并说明作者,诗名

2、请自己写一句下半句,不允许使用原诗句,尽量保持对仗和结构,并简单说明思
考过程

3. 题面:

某日,三位武林人士约定比武以决定谁能作为百度公司的武侠形象代言人,他们分别是
李寻欢、段誉、韦小宝。

他们的武功情况如下:李寻欢武功最高,命中率a(即出招时命中目标的概率);段誉次
之,命中率b;韦小宝较弱,命中率c 且1>a>b>c>0

比武规则:为了以示公平,每一轮按照如下先后顺序出招--韦小宝先出招,段誉第二个
,李寻欢最后,轮到某人出招时,可以自由选择仍未出局的人为目标发招,被命中的人
将成为败者并立即退出比武。按照这样的顺序循环进行,直到最后剩下1人为止,成为胜

问题:

1、这三个人是三本武侠作品中的人物,请列出这三本武侠作品以及作者,并选取其中一
本,用尽可能精炼的语言描述其故事梗概。

2、假设这3人都是绝顶聪明的,即他们均按照最利于自己获胜的方式选择目标,那么请
问,谁最有可能成为百度的武侠形象代言人,每个人获胜的几率分别为多少?请给出推
演方法和思路

3、如果本题不进行计算,直接猜测答案,你将如何回答,为什么?

4. 问题:

1、著名的牛顿定律,都包含哪几个?请用精炼的语言描述他们,并针对每一个列出其在
现实生活中的至少一项应用

2、请选取牛顿定律中的一个或多个,谈谈对于你人生的启发

5. 题面:这里有一个等式: 6+6-317=329

问题:这个等式不是一个有效的数学表达式,请在其中画一条直线,使之变成有效的数
学表达式。请注意至少提供5种方法

6. 题面:

靠近珠江码头的一只船上的一边船舷上悬吊着一架绳梯,绳梯一共有20个横档。自上而
下数第11根横档刚刚浸入水中。已知江水以每小时1.2厘米的速度上涨。每两根横档之间
的距离是8厘米,每根横档的厚度是0.75厘米。

问题:请问24小时后浸入在水中的横档有几根?48小时后呢?

7. 问题:请列出你选择一份工作的最重要三条标准,简述原因

8. 题面:

四个亲戚在一块度过了愉快的一天,尽管只有4人,但是他们却构成一个大家庭。这四个
人中包括一个父亲和一个母亲、一个儿子和一个女儿、一个姐姐和一个弟弟(或一个哥
哥和一个妹妹)、一个舅舅和一个舅妈、一个侄子和一个侄女、以及两个堂(或表)兄
妹(或姐弟)。

所有这些关系是发生在这4人之间(即如果某人是父亲,则他必是另外三人中某人或某些
人的父亲,依次类推)。

这4个人之间不存在其它的婚姻关系。

问题:

请分析这是为什么?并说明思考过程

9. 问题:请最简洁的语言,精确的描述一种游戏规则

10. 问题:1、请列出至少6种百度的产品,其中至少包含2项商业性的产品

2、请挑选列出的商业性产品中的一种,用最精炼的语言描述该产品并简述你理解的该
产品的核心内容(如果列不出商业性的,可以列非商业的,但会相应扣分)

11. 题面:

DONALD+GERALD=ROBERT

上面等式中的每个字母都代表一个0~9的自然数

问题:请分析并列出各个字母代表的数字

12. 题面:某建筑师酷爱对称,他想在公园中种植4棵树,要求每棵树距离其它三棵树是
一样的(距离的定义以树根与地面的接触部来计算)

问题:请问该如何种植?请列出所有你想到的可能,并说明分析过程

13. 题面:某另外一个建筑师,他想在公园中种植10棵树,要求种成5排,每排4棵,且
每一排上相邻树的距离是一样的(距离的定义同样以树根与地面的接触部来计算)

问题:请问该如何种植?请列出所有你想到的可能,并说明分析过程

如果是12棵树,要求种成6排,同样每排4棵,该如何进行?

14. 题面:两个对手玩一个游戏,桌上有标有1~9自然数的9张卡片,游戏规则是轮流从
桌上的剩余卡片中取一张纸片,最先使得两人取出的卡片的数字之和等于15的人获胜。


问题:请问是否存在先手必胜或者后手必胜的方法,如果有,请列出,并说明分析方法


15. 题面:假如你是一家国内顶尖的笔记本电脑制造公司的负责新产品的项目经理,公
司决定推出面向大学生的笔记本,以打开和开拓这方面的市场。

问题:请提供你的项目方案及思考本问题的思路,包括步骤、时间表、人员管理、成本
控制,以及可能出现的风险点和应对方案等。请注意方案的完整性和合理性,不必拘泥
于细节

16. 题面:

三个警察和三个囚徒共同旅行。一条河挡住了去路,河边有一条船,但是每次只能载2人
。存在如下的危险:无论在河的哪边,当囚徒人数多于警察的人数时,将有警察被囚徒
杀死。

问题:请问如何确定渡河方案,才能保证6人安全无损的过河

备注:题目顺序与难度无关,答满10道题即为及格,多答可有加分;2、7、14、10、3、
15必答

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1.已知strcpy 函数的原型是: char *strcpy(char *strDest, const char *strSrc); 其中strDest 是目的字符串,strSrc 是源字符串。不调用C++/C 的字符串库函数, 请编写函数 strcpy 答案: char *strcpy(char *strDest, const char *strSrc) { if ( strDest == NULL || strSrc == NULL) return NULL ; if ( strDest == strSrc) return strDest ; char *tempptr = strDest ; while( (*strDest++ = *strSrc++) != ‘\0’) ; return tempptr ; } 3.12 main 函数执行以前,还会执行什么代码? (Autodesk) 答案:全局对象的构造函数会在main 函数之前执行。 3.13 描述内存分配方式以及它们的区别。 (Autodesk , Microsoft) 答案:1) 从静态存储区域分配。内存在程序编译的时候就已经分配好,这块 内存在程序的整个运行期间都存在。例如全局变量,static 变量。 (2) 在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上 创建,函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理 器的指令集。 (3) 从堆上分配,亦称动态内存分配。程序在运行的时候用malloc 或new 申 请任意多少的内存,程序员自己负责在何时用free 或delete 释放内存。动态内 存的生存期由我们决定,使用非常灵活,但问题也最多。 3.14 什么是虚拟存储器?virtual memory 怎样映射到physical memory?页面替换 算法有哪些? (Microsoft) 见操作系统 p238 页。掌握的页面替换算法NRU,FIFO,第二次机会页面替换 算法,LRU 3.15 有四个同样的容器,里面装满了粒数相同的药丸,正常药丸的质量为m,变 质药丸的质量为m+1,现在已知这四个容器中,有一个装的全是变质药丸,用电 子秤只称一次,找出哪个容器装的是变质药丸(Microsoft) 答案:把四个容器依次编号为1、2、3、4,然后从中分别取出1、2、3、4 粒药 丸,称这10 粒药丸的质量,如果质量为10m+1,则说明第一个容器装的是变质药 丸,如果为10m+2 则说明第二个装的变质药丸,依次类推。 3.16 比较一下C++中static_cast 和 dynamic_cast 的区别。 (Autodesk) 。。。。。。。。。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值