微软实习生笔试题目
strcpy(a, "abcdcccd");
cout<
return 0;
}
A. abdcccd B. abdd C. abcc D. abddcccd E. Access violation
Choose: D
16. What is the complexity of the result call of power(b, e) in the follow code?
int power(int b, int e) {
if(e==0) return 1;
if(e%2 == 0) return power(b*b, e/2);
return b*power(b*b,e/2);
}
A. logarithmic B. linear C. quadratic D. exponentical
Choose: A
17. Take 2 cards from one full poker(52 cards, 26 red and 26 black) and half poker each, what is the probability of the event that two cards are both red?
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
Choose: B
18. How many kinds of output of stack with the input 1,2,…,n?
B. C_2n^n-C_2n^(n+1) C. ((2n)!)/(n+1)n!n! D. n! E. none
Choose: C
19. What is the minimum time and space complexity to compute the Largest Increased Subsequence(LIS) of array?
A. N^2,N^2 B. N^2,N C. NlogN,N D. N, N E. N,C
Choose: C
20. What is the output of the follow code?
struct Item{
char c;
Item *next;
};
Item* f1(Item* x){
Item *prev = NULL;
Item *curr = x;
while(curr) { Item *next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
return prev;
}
void f2(Item *x){
while(x){
cout<
x = x->next;
}
}
int main(int argc, char* argv[]){
Item *x, d = {'d', NULL}, c = {'c', &d}, b = {'b', &c}, a = {'a', &b};
x = f1(&a);
f2(x);
return 0;
}
Choose: dcba