微软校园招聘笔试题
A、static B、virtual C、extern D、inline E、const
15、What is the result of the following program?
[cpp] view plaincopyprint?char *f(char *str , char ch)
{
char *it1 = str;
char *it2 = str;
while(*it2 != '\0')
{
while(*it2 == ch)
{
it2++;
}
*it1++ = *it2++;
}
return str;
}
int main(void)
{
char *a = new char[10];
strcpy(a , "abcdcccd");
cout<
return 0;
}
char *f(char *str , char ch)
{
char *it1 = str;
char *it2 = str;
while(*it2 != '\0')
{
while(*it2 == ch)
{
it2++;
}
*it1++ = *it2++;
}
return str;
}
int main(void)
{
char *a = new char[10];
strcpy(a , "abcdcccd");
cout<
return 0;
}A、abdcccd
B、abdd
C、abcc
D、abddcccd
E、Access violation
16、Consider the following definition of a recursive function,power,that will perform exponentiation.
[cpp] view plaincopyprint?int power(int b , int e)
{
if(e == 0)
return 1;
if(e % 2 == 0)
return power(b*b , e/2);
else
return b * power(b*b , e/2);
}
int power(int b , int e)
{
if(e == 0)
return 1;
if(e % 2 == 0)
return power(b*b , e/2);
else
return b * power(b*b , e/2);
}Asymptotically(渐进地) in terms of the exponent e,the number of calls to power that occur as a result of the call power(b,e) is
A、logarithmic
B、linear
C、quadratic
D、exponential
17、Assume a full deck of cards has 52 cards,2 blacks suits (spade and club) and 2 red suits(diamond and heart). If you are given a full deck,and a half deck(with 1 red suit and 1 black suit),what is the possibility for each one getting 2 red cards if taking 2 cards?
A、1/2 1/2
B、25/102 12/50
C、50/51 24/25
D、25/51 12/25
E、25/51 1/2
18、There is a stack and a sequence of n numbers(i.e. 1,2,3,...,n), Push the n numbers into the stack following the sequence and pop out randomly . How many different sequences of the n numbers we may get? Suppose n is 2 , the output sequence may 1,2 or 2,1, so wo get 2 different sequences .
A、C_2n^n
B、C_2n^n - C_2n^(n+1)
C、((2n)!)/(n+1)n!n!
D、n!
E、None of above
19、Longest Increasing Subsequence(LIS) means a sequence containing some elements in another sequence by the same order, and the values of elements keeps increasing.
For example, LIS of {2,1,4,2,3,7,4,6} is {1,2,3,4,6}, and its LIS length is 5.
Considering an array with N elements , what is the lowest time and space complexity to get the length of LIS?
A、Time : N^2 , Space : N^2
B、Time : N^2 , Space : N
C、Time : NlogN , Space : N
D、Time : N , Space : N
E、Time : N , Space : C
20、What is the output of the following piece of C++ code ?
[cpp] view plaincopyprint?#include
上一页 [1] [2] [3] [4] [5] [6] 下一页