This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 微软面试题求解, 多谢。
-tonyhao(tonyhao);
2007-4-5
{598}
(#3596764@0)
-
C语言的大侠都跑哪去了?
-tonyhao(tonyhao);
2007-4-5
(#3596814@0)
-
Your question 1
remove((char*)myints+*(unique( myints, myints+sizeof(myints)/sizeof(int) ))+2);
-interview(intervieweree);
2007-4-5
(#3596990@0)
-
remove((char*)myints+*(unique( myints, myints+sizeof(myints)/sizeof(int) ))+2);
-interview(intervieweree);
2007-4-5
(#3596992@0)
-
没看懂, 能写成程序吗?
-tonyhao(tonyhao);
2007-4-5
(#3597025@0)
-
by using STL functions, you dont see a interim value in your code. I think this is the purpose of the test. Do you really believe no interim value will be used to swap values?
-interview(intervieweree);
2007-4-5
(#3597039@0)
-
sorry, swap value does not need intermediate variable.
-interview(intervieweree);
2007-4-5
(#3597046@0)
-
微软都是让用C语言写, 不能用STL
-tonyhao(tonyhao);
2007-4-5
(#3597050@0)
-
要求用标准C语言写。
-tonyhao(tonyhao);
2007-4-5
(#3597116@0)
-
Q1:int UniqueArray(int *arr, int size)
{
int i, j = 1;
for (i = 1; i < size; i++)
{
if (arr[j-1] != arr[i])
{
arr[j] = arr[i];
j++;
}
}
return j;
}
-shz(shz);
2007-4-5
{224}
(#3597967@0)
-
what if size==0? and if there is no duplication, all elements are unnecessarily assigned, so arr[j] = arr[i]; is needed only when i!=j
-wangqingshui(忘情水);
2007-4-5
(#3598034@0)
-
第一道题的答案(程序)见内,供参考。
-mike20030405(麦客);
2007-4-7
{1586}
(#3600320@0)
-
第13行如果改为printf("]\n ");输出会更清楚些。
-mike20030405(麦客);
2007-4-7
(#3600327@0)
-
I prefer input[offset] over *(input+offset) for better readability. If I'd like to increase performance, I'd replace *(input+offset) with *next (of type int*) and ++offset with ++next.
-wangqingshui(忘情水);
2007-4-8
(#3600954@0)
-
good point!
-mike20030405(麦客);
2007-4-8
(#3601888@0)
-
第二道题答案(程序),供参考。
-mike20030405(麦客);
2007-4-7
{2993}
(#3600441@0)
-
2个int的最大偶数,相乘后不是int了吧, 该用long吧
-tonyhao(tonyhao);
2007-4-8
(#3601106@0)
-
good point!!
-mike20030405(麦客);
2007-4-8
(#3601889@0)
-
2 minor concerns: 1. operator % can be used. 2. sequence of conditions can be reordered to ommit no action conditions like if (*input < the_less_even) ;
-wangqingshui(忘情水);
2007-4-8
(#3601127@0)
-
good point!
-mike20030405(麦客);
2007-4-8
(#3601890@0)