首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

微软2012暑期见习笔试题(附答案)

2012-08-03 
微软2012暑期实习笔试题(附答案)1. Suppose that a Selection Sort of 80 items has completed 32 iterati

微软2012暑期实习笔试题(附答案)

1. Suppose that a Selection Sort of 80 items has completed 32 iterations of the main loop. How many items are now guaranteed to be in their final spot (never to be moved again)?
对80个数进行选择排序,执行32个循环后,有多少个数已经固定位置?
(A) 16 (B) 31 (C) 32 (D) 39 (E) 40
Ans: C,考虑逆序的情况

2. Which synchronization mechanism(s) is/are used to avoid race conditions among processes/threads in operating system?
下列哪些机制可以避免进程(线程)间的竞争条件?
(A) Mutex (B) Mailbox (C) Semaphore (D) Local procedure call
Ans: A C,互斥量和信号量

3. There is a sequence of n numbers 1,2,3, ...,n and a stack which can keep m numbers at most. Push the n numbers into the stack following the sequence and pop out randomly. Suppose n is 2 and m is 3, the output sequence maybe 1,2 or 2,1, so we get 2 different sequence. Suppose n is 7 and m is 5, please choose the output sequence of the stack.
(A) 1,2,3,4,5,6,7
(B) 7,6,5,4,3,2,1
(C) 5,6,4,3,7,2,1
(D) 1,7,6,5,4,3,2
(E) 3,2,1,7,6,5,4
Ans: A C E

4. What is the result of binary number 01011001 after multiplying 0111001 and adding 1101110?
(A) 0001010000111111
(B) 0101011101110011
(C) 0011010000110101
Ans: A

5. What is output if you compile and execute the following C code?

#include <iostream>using namespace std;struct Item{    char c;    Item *next;};Item *Routine1(Item *x){    Item *prev = NULL, *curr = x;    while(curr)    {        Item *next = curr->next;        curr->next = prev;        prev = curr;        curr = next;    }    return prev;}void Routine2(Item *x){    Item *curr = x;    while(curr)    {        cout<<curr->c<<" ";        curr = curr->next;    }}void _tmain(void){    Item *x,        d = {'d', NULL},        c = {'c', &d},        b = {'b', &c},        a = {'a', &b};    x = Routine1(&a);    Routine2(x);}
(A) c b a d   (B) b a d c   (C) d b c a   (D) a b c d   (E)d c b a
Ans: E,函数的作用是将链表反转

原题请参考百度文库:http://wenku.baidu.com/view/292c0c6027d3240c8447ef5a.html

转载请注明出处:nevasun的专栏

热点排行