微软暑期实习生笔试题.docx

上传人:b****2 文档编号:17358181 上传时间:2023-07-24 格式:DOCX 页数:11 大小:125.46KB
下载 相关 举报
微软暑期实习生笔试题.docx_第1页
第1页 / 共11页
微软暑期实习生笔试题.docx_第2页
第2页 / 共11页
微软暑期实习生笔试题.docx_第3页
第3页 / 共11页
微软暑期实习生笔试题.docx_第4页
第4页 / 共11页
微软暑期实习生笔试题.docx_第5页
第5页 / 共11页
微软暑期实习生笔试题.docx_第6页
第6页 / 共11页
微软暑期实习生笔试题.docx_第7页
第7页 / 共11页
微软暑期实习生笔试题.docx_第8页
第8页 / 共11页
微软暑期实习生笔试题.docx_第9页
第9页 / 共11页
微软暑期实习生笔试题.docx_第10页
第10页 / 共11页
微软暑期实习生笔试题.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

微软暑期实习生笔试题.docx

《微软暑期实习生笔试题.docx》由会员分享,可在线阅读,更多相关《微软暑期实习生笔试题.docx(11页珍藏版)》请在冰点文库上搜索。

微软暑期实习生笔试题.docx

微软暑期实习生笔试题

答案仅供参考-更改了部分个人认为不严谨的答案,以及一点点注释

1.Whichofthefollowingcallingconvention(s)support(s)supportvariable-lengthparameter(e.g.printf)?

(3Points)

  A.cdecl  

  B.stdcall  

  C.pascal  

D.fastcall

注:

可变参数函数需要由调用者清栈,因为当前函数并不知道要有多少参数被传入,所以必须用cdcel

2.What'stheoutputofthefollowingcode?

(3Points)

1.class A  

2.{  

3.public:

  

4.    virtual void f()  

5.    {  

6.        cout<<"A:

:

f()"<

7.    }  

8.    void f() const  

9.    {  

10.        cout<<"A:

:

f() const"<

11.    }  

12.};  

13.  

14.class B:

 public A  

15.{  

16.public:

  

17.    void f()  

18.    {  

19.        cout<<"B:

:

f()"<

20.    }  

21.    void f() const  

22.    {  

23.        cout<<"B:

:

f() const"<

24.    }  

25.};  

26.  

27.void g(const A* a)  

28.{  

29.    a->f();  

30.}  

31.  

32.int main()  

33.{  

34.    A* a = new B();  

35.    a->f();  

36.    g(a);  

37.    delete a ;  

38.}  

  A.B:

:

f()B:

:

f()const  

  B.B:

:

f()A:

:

f()const  

  C.A:

:

f()B:

:

f()const  

D. A:

:

f()A:

:

f()const 

注:

const类指针只可以调用const类方法

3.Whatisthedifferencebetweenalinkedlistandanarray?

(3Points)

  A.Searchcomplexitywhenbotharesorted

  B.Dynamicallyadd/remove

  C.Randomaccessefficiency

  D.Datastoragetype

4.AbouttheThreadandProcessinWindows,whichdescription(s)is(are)correct:

(3Points)

  A.OneapplicationinOSmusthaveoneProcess,butnotanecessarytohaveoneThread

  B.TheProcesscouldhaveitsownStackbutthethreadonlycouldsharetheStackofitsparentProcess

  C.ThreadmustbelongstoaProcess

  D.ThreadcouldchangeitsbelongingProcess

5.Whatistheoutputofthefollowingcode?

(3Points)

1.{  

2.  int x = 10 ;  

3.  int y = 10 ;  

4.  x = x++ ;  

5.  y = ++y ;  

6.  printf("%d, %d\n",x,y);  

7.}  

  A.10,10

  B.10,11

  C.11,10

D.11,11

注:

这是道错题。

根据ANSI/ISOC标准描述:

“在上一个和下一个序列点之间,一个对象所保存的值至多只能被表达式的求值修改一次,而且只有在确定将要保存的值的时候才能访问前一个值。

”像x=x++,y=++y这样两次修改同一个变量的表达式是绝不允许的(或者,无论如何都无需明确定义,也就是说,无需知道它们到底做什么,编译器也不必支持它们。

引用至《你必须知道的495个C语言问题》,人民邮电出版社,37页

这种题多见于谭浩强老爷爷出的C教程书。

可想而知微软程序员也是看这本书长大的。

6.ForthefollowingJavaorC#code(3Points)

1.int [][] myArray3 =  

2.new int[3][]{  

3.  new int[3]{5,6,2},  

4.  new int[5]{6,9,7,8,3},  

5.  new int[2]{3,2}};  

  WhatwillmyArray3[2][2]

  returns?

  A.9

  B.2

  C.6

  D.overflow

7.Pleasechoosetherightstatementaboutconstusage:

(3Points)

  A.constinta;//constinteger

  B.intconsta;//constinteger

  C.intconst*a;//apointerwhichpointtoconstinteger

  D.constint*a;//aconstpointerwhichpointtointeger

  E.intconst*a;//aconstpointerwhichpointtointeger

8.Giventhefollowingcode:

(3Points)

1.#include   

2.  

3.class A{  

4.public:

  

5.    long a;  

6.};  

7.  

8.class B :

 public A  

9.{  

10.public:

  

11.    long b;  

12.};  

13.  

14.void seta(A* data, int idx)  

15.{  

16.    data[idx].a = 2;  

17.}  

18.  

19.int _tmain(int argc, _TCHAR *argv[])  

20.{  

21.    B data[4];  

22.  

23.    for(int i=0; i<4; ++i)  

24.    {  

25.        data[i].a = 1;  

26.        data[i].b = 1;  

27.        seta(data, i);  

28.    }  

29.  

30.    for(int i=0; i<4; ++i)  

31.    {  

32.        std:

:

cout<

33.    }  

34.  

35.    return 0;  

36.}  

  Whatisthecorrectresult?

  A.11111111

  B.12121212

  C.11112222

  D.21212121

 【此题答案貌似应该是22221111】

注:

答案确实是22221111。

我就不吐槽什么了。

因为没有虚函数,所以没有4字节的虚函数表,这样一个B类对象就是8字节,A类对象是4字节。

在seta函数中,取A[1]对象时,程序会跳过4字节(而不是一个正常B对象应该跳过的8字节),所以取A[1]的a实际上得到的是B[0]的a,取A[0]的a实际上得到的是B[0]的b。

9.1of1000bottlesofwaterispoisonedwhichwillkillaratin1weekiftheratdrunkanyamoutofthewater.Giventhebottlesofwaterhavenovisualdifference,howmanyratsareneededatleasttofindthepoisonedonein1week?

(5Points)

  A.9

  B.10

  C.32

D.Noneoftheabove

注:

给1~1000的瓶子二进制编号,10个老鼠按位站好,哪个瓶子在这一位上是1就给这只老鼠喝一点。

最后看那些老鼠死了,该位置1,得出的数就是毒瓶。

10.Whichofthefollowingstatement(s)equal(s)value1inCprogramminglanguage?

(5Points)

  A.thereturnvalueofmainfunctionifprogramendsnormally

  B.return(7&1)

  C.char*str="microsoft";returnstr=="microsoft"

  D.return"microsoft"=="microsoft"

E.Noneoftheabove

注:

显然这份答案的作者不知道有个优化叫做“启用字符串池”(VS里的/GF)。

如果不启用此优化,那么任意两个即使相等的字符串常量也会被存为两个副本,这样C和D的指针比较就会失败。

11.Ifyoucomputed32bitsignedintegersFandGfrom32bitsignedXusingF=X/2andG=(X>>1),andyoufoundF!

=G,thisimpliesthat(5Points)

  A.Thereisacompilererror

  B.Xisodd

  C.Xisnegative

  D.F-G=1

  E.G-F=1

12.Howmanyrectanglesyoucanfindfrom3*4grid?

(5Points)

  A.18

  B.20

  C.40

  D.60

  E.Noneofaboveiscorrect

13.Onelinecansplitasurfaceto2part,2linecansplitasurfaceto4part.Given100lines,notwoparallellines,notreelinesjoinatsamepoint,howmanypartscan100linesplit?

(5Points)

  A.5051

  B.5053

  C.5510

D.5511

注:

高二找规律题。

n(n+1)/2+1

14.Whichofthefollowingsortingalgorithm(s)is(are)stablesorting?

(5Points)

  A.bubblesort

  B.quicksort

  C.heapsort

  D.mergesort

E.Selectionsort

注:

稳定是指(任意)两个相等的元素,排序前后其相对前后位置不变。

选择排序、快速排序、希尔排序、堆排序不是稳定的排序算法,而冒泡排序、插入排序、归并排序和基数排序是稳定的排序算法。

15.Model-View-Controller(MVC)isanarchitecturalpatternthatfrequentlyusedinwebapplications.Whichofthefollowingstatement(s)is(are)correct:

(5Points)

  A.Modelsoftenrepresentdataandthebusinesslogicsneededtomanipulatethedataintheapplication

  B.Aviewisa(visual)representationofitsmodel.Itrendersthemodelintoaformsuitableforinteraction,typicallyauserinterfaceelement

  C.Acontrolleristhelinkbetweenauserandthesystem.Itacceptsinputfromtheuserandinstructsthemodelandaviewtoperformactionsbasedonthatinput

  D.ThecommonpracticeofMVCinwebapplicationsis,themodelreceivesGETorPOSTinputfromuseranddecideswhattodowithit,handingovertocontrollerandwhichhandcontroltoviews(HTML-generatingcomponents)

  E.Noneoftheabove

16.wecanrecoverthebinarytreeifgiventheoutputof(5Points)

  A.Preordertraversalandinordertraversal

  B.Preordertraversalandpostordertraversal

  C.Inordertraversalandpostordertraversal

  D.Postordertraversal

17.Givenastringwithncharacters,supposeallthecharactersaredifferentfromeachother,howmanydifferentsubstringsdowehave?

(5Points)

  A.n+1

  B.n^2

  C.n(n+1)/2

  D.2^n-1

  E.n!

18.Giventhefollowingdatabasetable,howmanyrowswillthefollowingSQLstatementupdate?

(5Points)

  A.1

  B.2

  C.3

  D.4

  E.5

19.WhatistheshortestpathbetweennodeSandnodeT,giventhegraphbelow?

Note:

thenumbersrepresentthelengthsoftheconnectednodes.(13Points)

   

  A.17

  B.18

  C.19

  D.20

E.21

注:

从T开始往前倒退,非常简单

20.GivenasetofNballsandoneofwhichisdefective(weighslessthanothers),youareallowedtoweighwithabalance3timestofindthedefective.WhichofthefollowingarepossibleN?

(13Points)

  A.12

  B.16

  C.20

  D.24

  E.28

注:

27以下都可以。

实际上,如果允许m次比较,那么N<=3^m都可以。

关键是要想到比如3个球,我们可以比较其中两个,不平衡当然知道哪个轻,平衡就是第三个轻。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2