微软面试题[1-2]
来源:互联网 发布:数据检索 编辑:程序博客网 时间:2024/05/01 07:17
1.Given a rectangular(cuboidal for the puritans) cake whith a rectangular piece removed (
any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife?
译:给定一块已在任意位置用任意方向切去一个矩形块的矩形蛋糕(注意是立体的,质量均匀的),怎样用一刀切出相等重量的两块来?
找出这两个矩形块的中心点m和n,然后切面a可以垂直矩形的任意面,但是必须过m和n点,这样切后的两块蛋糕在体积上是相等了
2. You're given anarray containing both positive and negative integers and required to find thesub-array with the largest sum (O(N) a la KBL). Write a routine in C for theabove.
一个矩阵中包含正数和负数,要求寻找和最大的子矩阵
int main()
{
int a[] ={ -2,30,-5,-13,-19,1,-3,2};
int len=8;
int sum=0,beg=0,end=0,maxBeg=0,maxEnd=0,maxSum=0,i=0;
maxBeg=i;
maxEnd=i;
while (i < len)
{
sum +=a [ i ];
if( sum > maxSum )
{
maxSum = sum;
maxEnd = end;
maxBeg = beg;
}
else if( sum < 0 )
{
beg = i + 1;
sum = 0;
}
i++;
end++;
}
printf("beg %d,end %d,sum %d",maxBeg,maxEnd,maxSum);
return 0;
}
- 微软面试题[1-2]
- 微软面试题 2
- 微软面试题【2】
- 微软面试题2
- 微软面试题2 .
- 微软面试题 1
- 微软面试题1
- 微软面试题 07012012[2]
- 微软面试题 07022012 [2]
- 微软面试题 07022012 [1]
- 微软面试题学习心得1
- 微软面试-微软面试题(2)
- 微软面试-微软面试题(1)
- 10. 微软面试题:题目:求1+2+…+n,
- 微软面试题汇总(2)
- 微软面试题汇总(2)
- 微软的面试题(答案)(2)
- 微软面试题程序(2)
- matlab 离散曲线图、连续曲线图、柱状图
- 应用系统单点登录系统开发文档
- RedHat linux下安装WebSphere7中文乱码解决方法
- 精益软件度量——实践者的观察与思考
- Java基本类型与byte数组之间相互转换
- 微软面试题[1-2]
- Sgu 102. Coprimes
- Linux SVN 服务器配置以及客户端使用
- LA 3942 Remember the Word
- SSO单点登录系统WEB Service代码
- sql+datagridview 更新数据库
- 问题四十七: 有等式[※×(※3+※)]2=8※※9,其中※处为1个数字,滴上了墨水无法辨认
- 向国外投稿需要注意些下面几点
- 【Unity3D插件】NGUI屏幕自适应