刚考完,开始觉得做的还好,下来把不确定的验证下,发现悲剧了好多。。
【刚刚(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.
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
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
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)
![](http://50vip.com/lib/ueditor/php/upload/20130406/13652568466253.jpg)
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的均可以)
==================================================================================================================================
附试卷图片(感谢网友提供):
---------------------------------------------------------------------------------------------------------
--------------------------------------------------
----------------------------------------------------------
-------------------------------------------
========================================
==========================