微軟2013年暑期實習招聘筆試回憶[已補充完整]

剛考完,開始覺得做的還好,下來把不確定的驗證下,發現悲劇了好多。。

【剛剛(20130415晚上)居然收到面試通知郵件。。。不知道那天能不能去。。。。】


總共20道選擇題,全部不定項。總分100分,時間75分鐘。去年時間是90分鐘的。。。。

1~8,做對3分,半對2分,錯誤-2分,不做0分

9~18,做對5分,半對3分,錯誤-3分,不做0分

19~20,做對13分,半對7分,錯誤-7分,不做0分




1、關於支持不定數量參數的方法(supportvariable parameters)有哪些?

(cdecl,stdcall,pascal,fastcall)

cdecl只有這一個。


2、以下代碼輸出的結果是:

class A
{
public:
    virtual void f()
    {
        cout<<"A::f"<<endl;
    }
    void f() const
    {
        cout<<"A::f const"<<endl;
    }
};

class B:public A
{
public:
    virtual void f()
    {
        cout<<"B::f"<<endl;
    }
    void f() const
    {
        cout<<"B::f const"<<endl;
    }
};

void g(const A* a)
{
    a->f();
}

int main()
{
    A *b = new B();
    b->f();
    g(b);
    return 0;
}


答案爲:

B::f A::f const

第一個b->f()爲動態綁定,輸出B::f沒問題,第二個,目前還沒弄明白,

感覺是由於函數g的參數有const,所以調用成員函數也是調用const版本,但是const版本的不是虛函數,不存在動態綁定,所以輸出A::f const。


3、linked list和array的區別,鏈表與數組的區別。

What is the difference between a linked list and an array?(3 Points)

   A. Search complexity when both are sorted

   B. Dynamically add/remove

   C. Random access efficiency

   D. Data storage type


4、線程Thread和進程Process的區別(下列關於...和...說法正確的是?)好像是指明瞭windows下的。

About the Thread and Process in Windows, which description(s) is(are) correct:(3 Points)

   A. One application in OS must have one Process, but not a necessary to have one Thread

   B. The Process could have its own Stack but the thread only could share the Stack of its parent Process

   C. Thread must belongs to a Process

   D. Thread could change its belonging Process


5、代碼:

    int i=10,j=10;
    i = i++;
    j = ++j;
    cout<<i<<","<<j;


問輸出結果:

使用g++編譯,直接警告這是未定義的。。。。。

當然也給出了結果11,11.

使用vc編譯,沒有任何警告,結果也是11,11.


6、給一個二維數組,求數組的[x][y]是多少(x,y是確定的數字)?Java/C#下的

For the following Java or C# code(3 Points)


int[][] myArray3 =
new int[3][]{
  new int[3]{5,6,2},
  new int[5]{6,9,7,8,3},
  new int[2]{3,2}};


What will myArray3[2][2] returns?

   A. 9

   B. 2

   C. 6

   D. overflow


答案是D越界。


7、關於const int x和const int * x和int const x的註釋表述是否正確。

Please choose the right statement about const usage:(3 Points)

   A. const int a; //const integer

   B. int const a; //const integer

   C. int const *a; //a pointer which point to const integer

   D. const int *a; //a const pointer which point to integer

   E. int const *a; // a const pointer which point to integer


AB選項沒有初始化,但是描述正確的是ABC,自己查查資料吧。

8、以下代碼輸出的結果是:

class C
{
public:
    long    a;
};

class D:public C
{
public:
    long b;
};

void seta(C *data, int index)
{
    data[index].a = 2;
}

int main()
{
    D data[4];
    cout<<sizeof(C)<<","<<sizeof(D)<<endl;
    for(int i=0;i<4;++i)
    {
        data[i].a = 1;
        data[i].b = 1;
        seta(data,i);
    }
    for(int i=0;i<4;++i)
    {
        cout<<data[i].a<<data[i].b;
    }
    return 0;
}


答案:22221111.

這個做錯了。。。。。覺得不可能這麼簡單,果然有貓膩。。

seta中,參數是基類C類型的指針,然後移動指針取對象並賦值,

但是main中往函數seta中傳遞的是派生類的對象數組的起始地址。。。

函數seta中,

data[index].a=2;

等價於:(*(data+index)).a=2;

這裏的data類型是參數列表中的C*,所以如果傳進來的data是派生類對象數組的起始地址,那麼指針data+index已經不再指向第index個對象了。

原因是C和D所佔內存不同。

自己慢慢體會吧。。。

給的答案裏好像沒有這個啊??難道這道題目最好的辦法就是空着?(你選哪個都會扣分)


9、1000瓶中有1瓶毒藥,喂老鼠,問至少多少隻老鼠,才能識別毒藥?

1 of 1000 bottles of water is poisoned which will kill a rat in 1 week if the rat drunk any amout of the water. Given the bottles of water have no visual difference, how many rats are needed at least to find the poisoned one in 1 week?(5 Points)

   A. 9

   B. 10

   C. 32

   D. None of the above

(2^n > 1000),n=10即可。


10.下列代碼輸出值爲1的是?(其中選項有return 1&7,return "ab" == "ab")

Which of the following statement(s) equal(s) value 1 in C programming language?(5 Points)

   A. the return value of main function if program ends normally

   B. return (7&1)

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

   D. return "microsoft"=="microsoft"

   E. None of the above


1&7=1;

gcc下會對"ab" == "ab"警告:比較字面值是未定義的行爲。但是結果也給出1.

還有一項是:char *s="abc";return s=="abc";

測試發現一般編譯器都會優化,但是g++會警告。。。

但。。。。。。。但是,這是微軟的筆試。。。


11、32位有符號數x,x/2不等於x>>1的情況?

If you computed 32 bit signed integers F and G from 32 bit signed X using F = X / 2 and G = (X>>1), and you found F!=G, this implies that


   A. There is a compiler error

   B. X is odd

   C. X is negative

   D. F - G = 1

   E. G - F = 1



12、3*4的表格grid,可能找出多少個方框?(6 0)

How many rectangles you can find from 3*4 grid?

   A. 18

   B. 20

   C. 40

    D. 60

   E. None of above is correct



13、一條直線可以將平面(surface)分2部分,2條可以分4部分,問100條可以分多少部分?

One line can split a surface to 2 part, 2 line can split a surface to 4 part. Given 100 lines, no two parallel lines, no tree lines join at same point, how many parts can 100 line split?

   A. 5051

   B. 5053

   C. 5510

   D. 5511


自己畫畫吧,我當時沒讀懂題意,空着。。。

微軟的surface。。。split。。。被自己切n多片兒……偷笑(感謝網友飛俠桑提供~ 


14、穩定的排序方法?(冒泡排序、快排、堆排序、希爾排序、歸併排序)

Which of the following sorting algorithm(s) is(are) stable sorting?

   A. bubble sort

   B. quick sort

   C. heap sort

   D. merge sort

   E. Selection sort



15、關於MVC中M、V、C的職責描述

Model-View-Controller(MVC) is an architectural pattern that frequently used in web applications. Which of the following statement(s) is(are) correct:

   A. Models often represent data and the business logics needed to manipulate the data in the application

   B. A view is a (visual) representation of its model. It renders the model into a form suitable for interaction, typically a user interface element

   C. A controller is the link between a user and the system. It accepts input from the user and instructs the model and a view to perform actions based on that input

   D. The common practice of MVC in web applications is, the model receives GET or POST input from user and decides what to do with it, handing over to controller and which hand control to views(HTML-generating components)

   E. None of the above



16、二叉樹的還原(必須要有中序,外加其他的任一一個)

we can recover the binary tree if given the output of

   A. Preorder traversal and inorder traversal

   B. Preorder traversal and postorder traversal

   C. Inorder traversal and postorder traversal

   D. Postorder traversal



17、n長度的string,求它substring子串的個數。

Given a string with n characters, suppose all the characters are different from each other, how many different substrings do we have?


   A. n+1

   B. n^2

   C. n(n+1)/2

   D. 2^n-1

   E. n!


 請弄清楚substring的定義。

好像我錯了。。。


18、sql執行,影響的結果條數?(涉及in、group、sum、having關鍵字)

Given the following database table, how many rows will the following SQL statement update?(5 Points)

   update book set numberofcopies = numberofcopies + 1 where bookid in (select bookid from book group by bookid having sum(numberofcopies) < 8)


   A. 1

   B. 2

   C. 3

   D. 4

   E. 5



19、單向圖的最短路徑?不需要算法,畫畫就出來了。放最後真浪費。。。那麼高的分數。。

What is the shortest path between node S and node T, given the graph below? Note: the numbers represent the lengths of the connected nodes


A. 17

   B. 18

   C. 19

   D. 20

   E. 21



20、有N個球,只有一個的質量和其他的不同,給你一個天平,允許稱3次(當然是沒有刻度的),問下面可能的N有?

Given a set of N balls and one of which is defective (weighs less than others), you are allowed to weigh with a balance 3 times to find the defective. Which of the following are possible N?

   A. 12

   B. 16

   C. 20

   D. 24

   E. 28


(<= 3 ^ 3的均可以)


==================================================================================================================================

附試卷圖片(感謝網友提供):


---------------------------------------------------------------------------------------------------------


--------------------------------------------------




----------------------------------------------------------


-------------------------------------------



========================================



==========================


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章