終於來北京了。參加了第一個面試,地點微軟大廈。
能記下的寫出來吧。
1.值類型與引用類型的區別以及寫出下列輸出:
int i = 200; object o = i; int j = (int)o; Console.WriteLine("o:{0},j:{1}",o,j);
2.寫出輸出:
public class A { public static int X = B.Y; public A() { ++X; } } public class B { public static int Y = A.X; static B() { ++Y; } } Console.WriteLine(A.X.Tostring()); Console.WriteLine(B.Y.Tostring());
3.查找一個數組中成員重復的次數,將該成員與出現次數對應輸出;
4.快速排序
//算法大意 /* 將數組第一個數作為參考變量,從前向后,將大於該數的值移動到該數的右邊,從后向前小於該數的值移動到該數的左邊,直到兩數相遇,不可分割為止。 然后遞歸,將0到剛才相遇的數的位置為一個子數組,相遇位置到結尾為第二個子數組,如此繼續直到子數組長度為1. */ public int QuickSort(int [] arra,int low ,int high) { //參考值 int key=arra[0]; //數組還可以切割 while(low<hgh) { //滿足條件,數組往前走,循環 while(key<array[high]&&low<high) --high //不滿足時,說明該數比key小,即交換位置 array[low]=array[high]; //滿足條件,數組往后走,循環 while(key>array[low]&&low<high) ++low; //否則將 大的數移動到右邊 array[high]=array[low]; } //循環結束時,high與low相等,數組不在分割成小數組,該成員的值即為key array[low]=key; return high; } public void Sort(int [] arr,int l,int h) { if(l>h) return; int index=QuickSort(arr,int l,int h) //左邊遞歸 Sort(arr,0,index-1); //右邊遞歸 Sort(arr,index+1,arr.Length-1); }
5.查找最長公共子字符串
(當時沒做出來,回去研究)