找回密码
 加入后院

QQ登录

只需一步,快速开始

搜索
查看: 1082|回复: 0

[面筋] Microsoft实习生面试时的笔试

[复制链接]
发表于 2011-5-19 10:33 | 显示全部楼层 |阅读模式
Microsoft实习生面试时的笔试
2 E% t& r" K4 n$ P6 w, m
6 [# i: V+ @" j. bzz/ E& C, o! f% A; L8 W& C$ D6 U- L- T

/ `6 h! O0 G( ^) a- V1 W: q                  (08年微软实习生)             ! r2 C/ Q5 P* V, C5 l/ g+ Y6 x
总共2大题
' L' b( L8 A. K, R第一题 (数据结构题)
- ?5 ?3 n7 \8 X2 U5 n/ \. T读程序 补充程序中缺少的部分 难度不大 3 _: ?$ ~+ t! F6 y) W8 m. F

, H# \( t$ A6 @! d$ q本次笔试程序的内容是数据结构中的线性表的链式存储
4 @. _, e* I9 c  u程序中出现需要补充的几个主要的函数:线性链表的创建,插入,删除,判断链表是否为循环链表。! k% f# h7 m+ f5 a( J
程序用c语言描述 ,指针一定要掌握好。0 }1 M2 [: P* r

4 c2 m- }9 c5 o6 Y- y3 t6 H, p以下程序自己所写0 C4 s; n7 g$ z! w. @+ O
仅供参考:
9 G" q6 X( ]( u# T  N" a(以下程序在vc6.0中编译通过)
# Y2 Q: @& j2 q( h
1 e3 B5 D" m# B2 \' c4 |9 j- Z, n) z
//Copyrights  huchen 5 E$ r; A1 L+ T; r$ f
//
$ {* P8 f1 R2 a3 t, i//描述:程序描述了单链表的创建,插入,删除
$ D3 N, r: F0 s% B//注意:判断是否循环链表由读者自己实现 9 E* `: g# G' ?# A" N6 R
//
9 h( y% ]4 n! p( I9 G. T) y; @, `//作者:胡琛 <huc87@126.com>
( b% I# Z1 p/ {  i- B//日期:2007-7-22, 16:38:25$ \" D" Z4 f  f- W2 {) s% `
#include <stdio.h>
( m6 e: S- D; {& {
8 A1 v' v! z7 C, |6 a#define ERROR_OK 0
! ?- `5 f7 W6 b#define ERROR_OUT_OF_MEMORY 13 C+ |" D$ _: g! S8 W
#define ERROR_OVERFLOW 21 C0 m) q+ B& E/ m$ e
/ a+ B9 x$ \5 z/ c( A7 f" Z6 t
struct LNode
+ F# X4 t# L/ K) D' i, x{9 t3 l* `6 P1 z. n& W& O4 F
    int data; 9 e4 V0 d- P  E* z
    LNode *next;
7 K6 ~9 T& k1 t9 j8 p/ R};
; H& z' ~0 G, |5 r, g//创建一个链表 length为要创建链表的大小, head为头指针
& G: L0 x" F" ~- I! S  T6 M( fint CreateList(LNode *&head, int length)
; w1 v: B. \0 x6 o3 i{5 [) M! x. f& k+ R' P* {
    head = new LNode();
! x, M8 M4 T* {) W' k    if(!head)4 l: h- z" L0 I  X7 _: ]: ^9 G
    {6 I- C: I, I7 s% v. p: {/ n
        return ERROR_OUT_OF_MEMORY;
$ N6 W5 D( v' ^4 ?; g    }
7 b$ `, i6 u; S3 a. j    head->next = NULL;8 L6 R* `" n, B& R0 U
    LNode *p;: `8 U* v$ i( `
    printf("please enter the element:\n");: K$ S" e' G. M- L* D! l4 S0 o! P! A
    for(int i = 0; i < length; ++i)
/ G* g. _$ L- ~) v7 t, }    {$ e9 u; o& s' ~2 D9 ^
        p = new LNode();  G/ y. f$ T, Z- O
        if(!p)9 I; ]; d4 O/ `
        {$ X. {1 I' J  ~4 U& S" i
            return ERROR_OUT_OF_MEMORY;
  j! V8 Y8 _% i# G        }
7 Y2 W0 [0 {" l8 q6 r$ G% B        scanf("%d", &(p->data));& r+ C5 E0 c# o! c1 e5 O; I: s
        p->next = head->next;0 S, \' M1 A% r" O
        head->next = p;
  s% B  L& F9 F$ x    }
/ A" Z4 F% |( C* |& `6 Z    return ERROR_OK;
; [$ I9 N- I! K, q, d' j}
7 ?6 p6 c5 h" t$ C) P7 j//插入一个节点
" o  |$ r! k! h7 H* `int Insert(LNode *head, int location)
; l) N) a1 X3 e" O{
9 ~- e4 H/ @+ T- M* K    int index = 1;- h; J' A5 _7 X, D& k5 D5 w, S
    while(index < location && head->next)
; T/ B: c4 P9 A$ v, A( m: R7 J    {  t9 \7 U  D/ R( z" }$ E! `+ [
        head = head->next;; I0 g! E2 T+ O- t$ c: P" j) C% B
        ++index;
" }, j5 Q- R' ?: y1 a9 N    }
1 {# N/ \" ]" U2 S    if(!(head->next))
( M* W# @# N2 Z5 @4 c4 b+ d; k7 c    {
$ |% S! k4 f, Z) T0 B! O, e4 M1 {$ D) H. m        printf("overflow!\n");2 A1 a4 @) `% M( ?/ i/ ^! g  ^7 h
        return ERROR_OVERFLOW;
! i  g1 J2 X' p; M" D9 |" q    }
* p% X9 n& g6 m6 u+ Y! g    LNode *p = new LNode();
* {, _1 g1 k% t& E  A    if(!p)
9 R- [, R8 }: Y9 x    {5 b* E# e& @( z# z: o, E
        return ERROR_OUT_OF_MEMORY;
3 h6 H& J: J, x& i7 a, t    }% g5 }$ c0 S; n! C8 F
    printf("input an number you want insert:\n");" Q+ N  s$ r+ j: x
    scanf("%d", &(p->data));
8 F. b& X; g  ^, [+ |1 \* T0 {    p->next = head->next;
; q' t' Z  S4 n" ~4 j0 ~; h( B    head->next = p;. p. e6 G& @9 |+ e2 Z
. n- S3 L2 T/ C& n
    return ERROR_OK;. d  S" `: u0 E9 j. S1 K
}
* |- I) v$ a! I( c: c//删除一个节点$ @$ J( p8 z! _; M$ n
int Delete(LNode *head, int location)6 l: J( _# Q' }5 ?4 @9 g, {. M
{
) D8 |5 q# y4 o$ l" S" S9 g) ?( L    int index = 1;
9 q: Z; U4 Y& \1 k7 s. B0 ?    while(index < location && head->next) //index 保证指针指向要插入位置的前一个节点, 4 G* [4 @( d: F; ]
    {                                      // 第2个条件保证指针越界后指向最后一个节点( e) Z3 R. L( q1 c
        head = head->next;
* t' y9 a- {* ]- U( y        ++index;
7 X* v( L# ]: M: ]$ h$ W( `9 a    }/ w' W/ Z9 {* C6 G0 e+ L: A* n, L
    if(!(head->next))
2 `0 g4 C5 z7 C, R    {
1 K4 d( v: o! x        printf("overflow!\n");
9 @' V" C& h0 M/ h. ]        return ERROR_OVERFLOW;& ]' w0 j1 H- u2 u/ m. d
    }
& P* N+ w; `0 |9 L# E9 X, t% Q    LNode *p = head->next;( p+ |4 t- Q" |- P- e2 i/ {  l
    head->next = p->next;* S* p2 k" C1 t" b+ e
    delete p;
8 ?# u1 x* q4 u; j  V    return ERROR_OK;+ t$ V! ?' O+ @+ j: q. a/ j+ i0 D
}
7 Q# C8 U& |& ~4 o' Vvoid ShowLinkList(LNode *head); K& o" P: g' t$ o2 ~& e
{6 u7 h: ~9 f* f( v, `1 D
    printf("LinkList:");
4 Y2 _8 n# }# V8 j- e    LNode *p = head->next;
0 p6 |# N9 o! r' z    while(p)) M( I2 x3 y; A; \
    {( h2 V* E* g9 H% C5 W
        printf("%d ", p->data);  i7 ^* z9 p0 o7 f/ P
        p = p->next;( j8 S1 S# \/ b- ~% @$ h, Y
    }
- V) o- I- ]: _( @    printf("\n");
7 n- B% }% R6 q: y}
; _3 r: g( a" J" Z0 Y- D% i& t$ _1 b4 t2 f! L5 B
void main()* ?# r; W( ~' g; B  H4 C
{) V, X, V- w4 Y' O) l' {
    ! [- R6 e- L! k- y
    LNode *head = NULL;
1 ~& P# n& f# e  o" i1 o    int initialLength,location;, n; M$ o. ]" U3 t' O
    7 U% y' x9 h+ O9 d
    printf("please input an number to initilize the LinkList:\n"); //初始化链表的元素个数
4 n# S. S* B: t% V9 \    scanf("%d", &initialLength);' f& a, G1 }* ?+ M- R) l

( \5 ^4 n  c' c, J0 u$ f    if(!CreateList(head, initialLength))' v4 g+ `$ E: [
    {
" f) W" B  p. Z7 `        printf("Create LinkList Success! \n");
; o& d* @3 i3 z3 C+ ]# C    }5 F1 h) a( x5 b9 l$ H: i
    ShowLinkList(head);
+ T5 n  G, T5 e+ H7 S1 W3 F$ |, p: g) `" ~3 {3 L4 g6 H  z: W, V
    printf("please input an location you want to insert to:\n");
9 j7 G+ f! \) Y, y% P- K4 G    scanf("%d", &location);
3 E: p  I7 R% R% @8 Q& b9 i0 b- \& _" n; R- s
    if(!Insert(head, location))( M# ]' T& d& b
    {
! Y+ ~( t6 V# u# E  \1 `: r3 L# g        printf("Insert success!\n");6 c) Q$ c# [8 s" L$ }
    }- V: }! X+ x5 \9 N6 o
    ShowLinkList(head);
% F$ i! ]( ]) b# E7 ?
$ X8 f5 j8 u. Y2 Q8 c: ^    printf("please input an location you want to delete:\n");% ~3 `+ z: G3 W; H9 q$ h( R6 i
    scanf("%d", &location);3 I2 E- C& _4 r' Z6 I

( f+ Z8 R8 Z8 d$ [2 q: F    if(!Delete(head, location))
4 v3 A9 s) _/ t3 i    {
: x8 j9 ~( U$ j; Y        printf("Delete success!\n");; j% u3 _' o$ J* ^4 D4 Z
    }2 u+ `6 `- e5 q( n5 j5 r
    ShowLinkList(head);
% K: L) _; r+ e( d( X; ^5 h) {# g}  h/ ^- x! t2 F8 ^/ O. _" [

2 t. |; a) l  I4 S第一题总结:把数据结构中的基础打牢(不可能一直考链表) - i+ r3 K% z- c% R
4 P" n+ m6 i( M8 M6 P
第二题9 y2 O, i) w+ Y
英译中
7 n6 J! q! X2 u- c/ N3 F英语文章:长度 和难度都跟四级中阅读理解的文章差不多  n6 w( E4 w$ N# ~

6 t4 T1 v9 Q# I3 h
  b! e8 i% v8 t……$ O3 S' |: Z5 R# \9 e# m, F
; U# P& N) i' G& o
http://bbs.aftjob.com/thread-607297-1-1.html
6 [0 O( Z5 N% c* n, }: _* u9 p! w# o8 g+ u, W$ Z
——' R" `$ \: ?5 X" w0 E! E, ^% h$ ?8 s0 n
微软(Microsoft)求职俱乐部
4 J8 T7 d+ P* o/ {: }- A0 Xhttp://bbs.aftjob.com/group-100-1.html
/ V: L" |1 z0 G9 W& b3 m0 k2 Q% X2012阿凡提求职手册——IT行业篇
1 K  L3 o3 z$ F" C- e, Lhttp://bbs.aftjob.com/thread-607158-1-1.html
0 E/ M7 n. n! k, {# P" c—— 8 X' Y9 c: n) x' |* f2 C
微软笔经篇$ E1 w9 B1 h2 S$ X
http://bbs.aftjob.com/thread-469556-1-1.html& \: b' s! U  f5 y! V8 W
微软2007年笔试题
7 K% D; u* }. s# S! Shttp://bbs.aftjob.com/thread-607298-1-1.html
+ b7 c1 W- }. v$ \; N: N微软今天的笔试题目(12月28日)
" x; p4 R5 |$ uhttp://bbs.aftjob.com/thread-29793-1-1.html
* I" z0 i- i- p! C; l; }5 W微软笔试题整理! C/ a- L# q1 G- U
http://bbs.aftjob.com/thread-607299-1-1.html  S, ]* i# V. @0 i9 B
——
6 X- \) c4 S0 ^3 a. m/ z9 w1 [阿凡提(aftjob.com)求职社区% Z+ J+ D0 J( l3 L
阿凡提求职俱乐部-国内第一家网络求职俱乐部,提供企业求职俱乐部和高校求职俱乐部交流平台。
& V7 y4 o* E! |( P8 m5 m$ C——
9 m* H* T! w* _4 }) |! p( `; W: F+ Z2 \$ v
, z2 u5 T  a& {& B- _
您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2026-7-29 08:10

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表