微軟亞洲技術支持中心

微軟亞洲技術支持中心 1. 進程(Process)和線程(Thread)的差別 2. 堆(Heap)與棧(stack)的差別 3. Windows是如何管理內存的 4. 介紹.Net和.Net的安全性 5. 客戶端如何訪問.Net組件實現Web Service 6. C/C++編譯器中虛表是如何完成的 7. 談談COM的線程模型, 然後討論進程內/外組件的差別 8. 談談IA32下的分頁機制 9. 給兩個變量,如何找出一個帶環單鏈表中是什麼地方出現環的 10. 在IA32中一共有多少種辦法從用戶態跳到內核態 11. 如果只想讓程序有一個實例運行,不能運行兩個,像winamp一樣,只能開一個窗口,怎樣實現 12. 如何截取鍵盤的響應,讓所有的'a'變成'b' 13. Apartment在COM中有什麼用,爲什麼要引入 14. 存儲過程是什麼,有什麼用,有什麼優點 15. Template有什麼特點,什麼時候用 16. 談談Windows DNA結構的特點和優點 微軟亞洲工程院 基礎題 1. regular expression不能描述的是? a)兩個連續偶數 b)兩個連續奇數 2. 程序分析 int s(int v) { int count=0; int x=v; while (x) { count++; x=x&(x-1) } return count; } s(9999)=? 3. 關於堆排序的東西,插入新的元素以後的結果 4. 關於C語言中,.h文件和.c文件之間的關係 5. 如果數據擴大兩倍,是向左,還是向右移動幾位的問題 6. 對二叉排序數,以什麼輸出(前序,中序,還是後續)輸出,是排列 7. 一個順序爲 1,2,3,4,5,6 的棧,依次進入一個隊列,然後再進棧, 順序是什麼? 8. 關於數組指針的的題目 9. 在編寫代碼是查找錯誤好還是用testing找好? 10. 好像是說編譯器可以修改type error的好處或不好。 程序設計部分 1 Translate MIPS assembly code into a function in C/C++ * your code should be concise * no any GOTOs/pointers MIPS code: func: li v0,0 li t0,0 l1: add t1,a0,a0 lb t2,0(t1) beq t2,zero,l3 bne t2,a1,l2 add v0,v0,1 l2: add t0,t0,1 j l1 l3: jr ra (caller register: t0~t9,a0~a3,v0~v1; callee s0~s7,ra) 然後列出了指令表,li是賦值,lb是將字段後第一個寄存器內容個字節的內容複製到第二個寄存器,beq是等值轉移ben是不等值轉移,j是無條件轉移,jr轉移至寄存器標示的內容. 2. 實現數組的插入、查找、刪除操作 arr爲指向數組的指針 len爲數組長度 count表示數組元素數目 出錯返回-1 int insert(int* arr, size_t len, size_t count, int val) 返回插入的數組索引 插入後要求對數組排序 出錯處理 int search(int* arr, size_t len, size_t count, int val) 要求返回所找到的元素 出錯處理 int remove(int* arr, size_t len, size_t count, int val) 要求返回刪除的元素值 出錯處理 測試部分 1. 你被分配到Internet Explorer研發部,(從核心到界面什麼都可以).你如何設計,開發和測試它? 2. 給你個DVD,你應當如何測試它,如果你的時間極其有限,你會測試什麼?爲什麼? 3. 給你一個字符比較函數strCmp(const char* string1,const char* string2)以及其返回值表明的意義,(>0,==0,<0),設計測試case 4. 一段字符串複製程序,指出其存在的錯誤和潛在缺陷 最後是個論述題目,只有這個題目是要用英文作答的,上面的都可以用Chinese 1) 問的是你在過去一年裏做出過什麼樣的重要決定,你爲什麼做出這樣的決定,這個決定對你的影響,你達到你作決定時期望的目標了沒.有什麼收穫. 2) 問的是你在過去一年裏遇到什麼樣的問題,你如何解決的,是和別人解決的還是自己解決的?你達到你作決定時期望的目標了沒,有什麼收穫。 微軟亞洲工程院筆試題 1. 找Bug int CopyStringCount(const char* Str) { int nCount = 0; char* pBuffer; pBuffer = new char[_MAX_PATH]; strcpy(pBuffer,Str); while(;pBuffer ;pBuffer++) if(pBuffer == '//') nCount ++; return nCount; } 2. 寫輸出 void foo(int p1[]) { *p1 += 5; } void bar(int p2[]) { p2[1] = 15; } void main() { int a[]={3,4,5}; int b[]={3,4,5}; int *p2; p2=&a[1]; bar(p2); printf("%i %i %i/n",a[0],a[1],a[2]); p2=&b[0]; p2++; foo(p2); bar(p2); printf("%i %i %i/n",b[0],b[1],b[2]); } 微軟亞洲工程院2004年第二輪筆試題 1. 找錯 struct S { int i; int * p; }; void main() { S s; int * p = &s.i; p[0] = 4; p[1] = 3; s.p = p; s.p[1] = 1; s.p[0] = 2; } 程序會在哪一行死掉 2. int CalcMean(int i) { static int s, c; s+=i; c++; return s/c; } 求CalcMeas( CalcMeas(3) )=? 3. int calc(int a,int b) { if(a >= b) return (a==b)?a:b; else return a+b+calc(++a,--b); } 求calc(1,5)等於? Mircosoft面試題 1.2.4 IQ題(是填空的最後兩題): 1、三個盒子,有一個有寶石,讓你先選一個。然後主持人在剩下的盒子中打開一個空盒子(主持人知道寶石在哪個盒子裏)。現在你有一次改變選擇的機會。你改不改? 2、 abcdef*2=cdefab cdefab*2=efabcd 每個字母代表一個數字 abcdef=? 2 編程題 (1) 寫一個CircularQueue() (2) 寫一個Merge函數。把兩個已排序的鏈表合併。兩個鏈表一個是升序,一個是降序。 3 設計(可用中文) 設計一個密碼對話框,用來保護用戶的文件。 (1) 寫出設計文檔 (2) 寫出各種功能的priority,以及爲什麼這樣設定。 (3) 如果開發人員根據你的要求實現了這個對話框,你準備如何測試它?寫出測試的各點。 4 測試(可用中文) (1) 已知有一個函數,它的功能是將字符串轉換成數字,你如何測試它?假設函數是這樣的形式:atoi(char *,int*) 。請列出所有可能的測試案例。 (2) 現在有一個Web搜索引擎,它說它擁有了搜索的功能。你怎樣測試它?請寫出你想要測試的各個方面以及方法。 5 要用英文做答opening question (1) 你曾經有過什麼非常有創意的想法?最好是軟件方面。 (2) 你想讓開發者添加一個他認爲不重要的功能,你會怎麼做?英文是: How would you convince a developer to add a featurethat the developer does not view as importart? Microsoft程序員常用面試題 1.鏈表和數組的區別在哪裏? 2.編寫實現鏈表排序的一種算法。說明爲什麼你會選擇用這樣的方法? 3.編寫實現數組排序的一種算法。說明爲什麼你會選擇用這樣的方法? 4.請編寫能直接實現strstr()函數功能的代碼。 5.編寫反轉字符串的程序,要求優化速度、優化空間。 6.在鏈表裏如何發現循環鏈接? 7.給出洗牌的一個算法,並將洗好的牌存儲在一個整形數組裏。 8.寫一個函數,檢查字符是否是整數,如果是,返回其整數值。(或者:怎樣只用4行代碼編寫出一個從字符串到長整形的函數?) 9.給出一個函數來輸出一個字符串的所有排列。 10.請編寫實現malloc()內存分配函數功能一樣的代碼。 11.給出一個函數來複制兩個字符串A和B。字符串A的後幾個字節和字符串B的前幾個字節重疊。 12.怎樣編寫一個程序,把一個有序整數數組放到二叉樹中? 13.怎樣從頂部開始逐層打印二叉樹結點數據?請編程。 14.怎樣把一個鏈表掉個順序(也就是反序,注意鏈表的邊界條件並考慮空鏈表)? Mircosoft經典面試題智力題 1. 爲什麼下水道的井蓋是圓的? 答:因爲圓井蓋不會掉進下水道去,因爲方井蓋對角線明顯長於邊長,稍微角度不對就掉進去了,其他非圓形井蓋也有這個問題。 2. 美國有多少輛車?(一個常見的類似問題是:美國有多少家加油站?) 答:大約一億輛車,算上公司的車,差不多平均每個家庭一輛車。 3. 美國有多少個下水道井蓋? 答:缺少數據,比如美國公路總長度之類的數據 4. 你讓某些人爲你工作了七天,你要用一根金條作爲報酬。這根金條要被分成七塊。你必須在每天的活幹完後交給他們一塊。如果你只能將這根金條切割兩次,你怎樣給這些工人分? 答:1/7,2/7,4/7,第一天給1/7,第二天拿2/7換1/7 5. 一列火車以每小時15英里的速度離開洛杉磯,朝紐約進發。另外一列火車以每小時20英里的速度離開紐約,朝洛杉磯進發。如果一隻每小時飛行25英里的鳥同時離開洛杉磯,在兩列火車之間往返飛行,請問當兩列火車相遇時,鳥飛了多遠? 答:用相對速度,距離是5L/7,L是兩城市之間的距離 6. 假設一張圓盤像唱機上的唱盤那樣轉動。這張盤一半是黑色,一半是白色。假設你有數量不限的一些顏色傳感器。要想確定圓盤轉動的方向,你需要在它周圍擺多少個顏色傳感器?它們應該被擺放在什麼位置? 答:兩個就可以了,挨着放。有一個探測器測到變色,緊跟着另一個測到,過一段時間纔有下一次。轉盤從第一個測到變色的轉向第二個。 7. 假設時鐘到了12點。注意時針和分針重疊在一起。在一天之中,時針和分針共重疊多少次?你知道它們重疊時的具體時間嗎? 8. 你有兩個罐子,分別裝着50個紅色的玻璃球和50個藍色的玻璃球。隨意拿起一個罐子,然後從裏面拿出一個玻璃球。怎樣最大程度地增加讓自己拿到紅球的機會?利用這種方法,拿到紅球的機率有多大? 答:一個瓶子裏裝一個紅球,其他都裝到另一個瓶子裏,取到紅球的概率是149/198 9. 中間只隔一個數字的兩個奇數被稱爲奇數對,比如17和19。證明奇數對之間的數字總能被6整除(假設這兩個奇數都大於6)。現在證明沒有由三個奇數組成的奇數對。 答:題目有問題,應該把所有的“奇數”改爲“質數”。原因是,質數對必然全是奇數,中間數字爲偶數。指數對都不能被三整數,所以中間的數可以被三整除。得證連續三個奇數必有一個可以被三整除,大於6的質數全不能被三整數。所以不存在。 10. 一個屋子有一個門(門是關閉的)和3盞電燈。屋外有3個開關,分別與這3盞燈相連。你可以隨意操縱這些開關,可一旦你將門打開,就不能變換開關了。確定每個開關具體管哪盞燈。 答:開兩個開關,過一段時間關一個,進去,一個燈亮,兩個燈滅,滅的燈有一個是熱的。 11. 假設你有8個球,其中一個略微重一些,但是找出這個球的惟一方法是將兩個球放在天平上對比。最少要稱多少次才能找出這個較重的球? 答:拿出六個球比,兩次可解決 12. 假設你站在鏡子前,擡起左手,擡起右手,看看鏡中的自己。當你擡起左手時,鏡中的自己擡起的似乎是右手。可是當你仰頭時,鏡中的自己也在仰頭,而不是低頭。爲什麼鏡子中的影像似乎顛倒了左右,卻沒有顛倒上下? 答:上下和左右的定義不同,上下是面對稱的,左右是旋轉對稱的 (如果兩隻眼睛是長成一上一下就好了) 13. 你有4瓶藥。每粒藥丸的重量是固定的,不過其中有一瓶藥受到了污染,藥丸的重量發生了變化,每個藥丸增加了一點重量。你怎樣一下子測出哪瓶藥是遭到污染的呢? 答:如果確切知道那一點重量是多少,可以採取一種方法:第二個瓶取一粒,第三個瓶去兩粒第四個瓶取三粒。稱重之後可以計算出。 如果不確切的知道,可以考慮使用三根繩子和三個滑輪。 14. 下面玩一個拆字遊戲,所有字母的順序都被打亂。你要判斷這個字是什麼。假設這個被拆開的字由5個字母組成: 答: 1) 共有多少種可能的組合方式? 26^5(可重複),26*25*25*24*23*22(不可重複) 2) 如果我們知道是哪5個字母,那會怎麼樣? 5! 3) 找出一種解決這個問題的方法。 窮舉試探法,把五個字母按權重排序,逐步變大序列權重,可保證完卻探索。 15. 有4個女人要過一座橋。她們都站在橋的某一邊,要讓她們在17分鐘內全部通過這座橋。這時是晚上。她們只有一個手電筒。最多隻能讓兩個人同時過橋。不管是誰過橋,不管是一個人還是兩個人,必須要帶着手電筒。手電筒必須要傳來傳去,不能扔過去。每個女人過橋的速度不同,兩個人的速度必須以較慢的那個人的速度過橋。 答:   第一個女人:過橋需要1分鐘;   第二個女人:過橋需要2分鐘;   第三個女人:過橋需要5分鐘;   第四個女人:過橋需要10分鐘。   比如,如果第一個女人與第4個女人首先過橋,等她們過去時,已經過去了10分鐘。如果讓第4個女人將手電筒送回去,那麼等她到達橋的另一端時,總共用去了20分鐘,行動也就失敗了。怎樣讓這4個女人在17分鐘內過橋?還有別的什麼方法? 第一次1和2過橋,共用2分鐘 1回來,共用3分鐘 3和4過橋,共用13分鐘 2回來,共用15分鐘 1和2過橋,共用17分鐘 1和2返回的次序可以相反 ,效果不變 16. 如果你有一個5夸脫的水桶和一個3夸脫的水桶,如何準確量出4夸脫的水? 答:裝滿3,3倒入5,裝滿3,3倒滿5,3中剩1夸脫。倒空5,將一夸脫倒入5,裝滿3,倒入 5即可。 17. 你有一袋糖,有紅色的,藍色的,綠色的。閉上眼睛,拿出兩塊顏色一樣的糖,你需要拿多少次才能確保有兩塊顏色相同的? 答:四次 (鴿籠原理) 18. 如果你有兩個桶,一個裝的是紅色的顏料,另一個裝的是藍色的顏料。你從藍色顏料桶裏舀一杯,倒入紅色顏料桶,再從紅色顏料桶裏舀一杯倒入藍顏料桶。兩個桶中紅藍顏料的比例哪個更高?通過算術的方式來證明這一點。 答:算術的方式來證明這一點。 設桶是杯子容量的k倍。藍倒入紅一杯,紅中藍的比例是1/(k+1)。倒回一杯,紅中藍色比例不變。藍中紅色比例是(k/(k+1))/k=1 /(k+1)。比例一樣大 Microsoft Interview Questions The following are actual questions from actual interviews conducted by Microsoft employees on the main campus. Microsoft Consultants are sometimes allowed to have a life, so questions asked of them during interviews don't really count and aren't listed. The questions tend to follow some basic themes: Riddles * Why is a manhole cover round? * How many cars are there in the USA? (A popular variant is "How many gas stations are there in the USA?") * How many manhole covers are there in the USA? * You've got someone working for you for seven days and a gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker? * One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they collide, how far will the bird have traveled? * Imagine a disk spinning like a record player turn table. Half of the disk is black and the other is white. Assume you have an unlimited number of color sensors. How many sensors would you have to place around the disk to determine the direction the disk is spinning? Where would they be placed? * Imagine an analog clock set to 12 o'clock. Note that the hour and minute hands overlap. How many times each day do both the hour and minute hands overlap? How would you determine the exact times of the day that this occurs? * You have two jars, 50 red marbles and 50 blue marbles. A jar will be picked at random, and then a marble will be picked from the jar. Placing all of the marbles in the jars, how can you maximize the chances of a red marble being picked? What are the exact odds of getting a red marble using your scheme? * Pairs of primes separated by a single number are called prime pairs. Examples are 17 and 19. Prove that the number between a prime pair is always divisible by 6 (assuming both numbers in the pair are greater than 6). Now prove that there are no 'prime triples.' * There is a room with a door (closed) and three light bulbs. Outside the room there are three switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door you can't change them. Identify each switch with its bulb. * Suppose you had 8 billiard balls, and one of them was slightly heavier, but the only way to tell was by putting it on a scale against another. What's the fewest number of times you'd have to use the scale to find the heavier ball? * Imagine you are standing in front of a mirror, facing it. Raise your left hand. Raise your right hand. Look at your reflection. When you raise your left hand your reflection raises what appears to be his right hand. But when you tilt your head up, your reflection does too, and does not appear to tilt his/her head down. Why is it that the mirror appears to reverse left and right, but not up and down? * You have 4 jars of pills. Each pill is a certain weight, except for contaminated pills contained in one jar, where each pill is weight + 1. How could you tell which jar had the contaminated pills in just one measurement? * The SF Chronicle has a word game where all the letters are scrambled up and you have to figure out what the word is. Imagine that a scrambled word is 5 characters long: 1. How many possible solutions are there? 2. What if we know which 5 letters are being used? 3. Develop an algorithm to solve the word. * There are 4 women who want to cross a bridge. They all begin on the same side. You have 17 minutes to get all of them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each woman walks at a different speed. A pair must walk together at the rate of the slower woman's pace. Woman 1: 1 minute to cross Woman 2: 2 minutes to cross Woman 3: 5 minutes to cross Woman 4: 10 minutes to cross For example if Woman 1 and Woman 4 walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Woman 4 then returns with the flashlight, a total of 20 minutes have passed and you have failed the mission. What is the order required to get all women across in 17 minutes? Now, what's the other way? * If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts? * You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same? * If you have two buckets, one with red paint and the other with blue paint, and you take one cup from the blue bucket and poor it into the red bucket. Then you take one cup from the red bucket and poor it into the blue bucket. Which bucket has the highest ratio between red and blue? Prove it mathematically. Algorithms * What's the difference between a linked list and an array? * Implement a linked list. Why did you pick the method you did? * Implement an algorithm to sort a linked list. Why did you pick the method you did? Now do it in O(n) time. * Describe advantages and disadvantages of the various stock sorting algorithms. * Implement an algorithm to reverse a linked list. Now do it without recursion. * Implement an algorithm to insert a node into a circular linked list without traversing it. * Implement an algorithm to sort an array. Why did you pick the method you did? * Implement an algorithm to do wild card string matching. * Implement strstr() (or some other string library function). * Reverse a string. Optimize for speed. Optimize for space. * Reverse the words in a sentence, i.e. "My name is Chris" becomes "Chris is name My." Optimize for speed. Optimize for space. * Find a substring. Optimize for speed. Optimize for space. * Compare two strings using O(n) time with constant space. * Suppose you have an array of 1001 integers. The integers are in random order, but you know each of the integers is between 1 and 1000 (inclusive). In addition, each number appears only once in the array, except for one number, which occurs twice. Assume that you can access each element of the array only once. Describe an algorithm to find the repeated number. If you used auxiliary storage in your algorithm, can you find an algorithm that does not require it? * Count the number of set bits in a number. Now optimize for speed. Now optimize for size. * Multiple by 8 without using multiplication or addition. Now do the same with 7. * Add numbers in base n (not any of the popular ones like 10, 16, 8 or 2 -- I hear that Charles Simonyi, the inventor of Hungarian Notation, favors -2 when asking this question). * Write routines to read and write a bounded buffer. * Write routines to manage a heap using an existing array. * Implement an algorithm to take an array and return one with only unique elements in it. * Implement an algorithm that takes two strings as input, and returns the intersection of the two, with each letter represented at most once. Now speed it up. Now test it. * Implement an algorithm to print out all files below a given root node. * Given that you are receiving samples from an instrument at a constant rate, and you have constant storage space, how would you design a storage algorithm that would allow me to get a representative readout of data, no matter when I looked at it? In other words, representative of the behavior of the system to date. * How would you find a cycle in a linked list? * Give me an algorithm to shuffle a deck of cards, given that the cards are stored in an array of ints. * The following asm block performs a common math function, what is it? cwd xor ax, dx sub ax, dx * Imagine this scenario: I/O completion ports are communictaions ports which take handles to files, sockets, or any other I/O. When a Read or Write is submitted to them, they cache the data (if necessary), and attempt to take the request to completion. Upon error or completion, they call a user-supplied function to let the users application know that that particular request has completed. They work asynchronously, and can process an unlimited number of simultaneous requests. Design the implementation and thread models for I/O completion ports. Remember to take into account multi-processor machines. * Write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value. * Write a function to print all of the permutations of a string. * Implement malloc. * Write a function to print the Fibonacci numbers. * Write a function to copy two strings, A and B. The last few bytes of string A overlap the first few bytes of string B. * How would you write qsort? * How would you print out the data in a binary tree, level by level, starting at the top? Applications * How can computer technology be integrated in an elevator system for a hundred story office building? How do you optimize for availability? How would variation of traffic over a typical work week or floor or time of day affect this? * How would you implement copy-protection on a control which can be embedded in a document and duplicated readily via the Internet? * Define a user interface for indenting selected text in a Word document. Consider selections ranging from a single sentence up through selections of several pages. Consider selections not currently visible or only partially visible. What are the states of the new UI controls? How will the user know what the controls are for and when to use them? * How would you redesign an ATM? * Suppose we wanted to run a microwave oven from the computer. What kind of software would you write to do this? * What is the difference between an Ethernet Address and an IP address? * How would you design a coffee-machine for an automobile. * If you could add any feature to Microsoft Word, what would it be? * How would you go about building a keyboard for 1-handed users? * How would you build an alarm clock for deaf people? Thinkers * How are M&Ms made? * If you had a clock with lots of moving mechanical parts, you took it apart piece by piece without keeping track of the method of how it was disassembled, then you put it back together and discovered that 3 important parts were not included; how would you go about reassembling the clock? * If you had to learn a new computer language, how would you go about doing it? * You have been assigned to design Bill Gates bathroom. Naturally, cost is not a consideration. You may not speak to Bill. * What was the hardest question asked of you so far today? * If MS told you we were willing to invest $5 million in a start up of your choice, what business would you start? Why? * If you could gather all of the computer manufacturers in the world together into one room and then tell them one thing that they would be compelled to do, what would it be? * Explain a scenario for testing a salt shaker. * If you are going to receive an award in 5 years, what is it for and who is the audience? * How would you explain how to use Microsoft Excel to your grandma? * Why is it that when you turn on the hot water in any hotel, for example, the hot water comes pouring out almost instantaneously? * Why do you want to work at Microsoft? * Suppose you go home, enter your house/apartment, hit the light switch, and nothing happens - no light floods the room. What exactly, in order, are the steps you would take in determining what the problem was? * Interviewer hands you a black pen and says nothing but "This pen is red."
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章