??xml version="1.0" encoding="utf-8" standalone="yes"?>日本欧美韩国一区三区,日韩欧美视频一区,亚洲精品一区久久久久久http://www.aygfsteel.com/nokiaguy/category/31410.htmlzh-cnSun, 03 Nov 2013 10:21:52 GMTSun, 03 Nov 2013 10:21:52 GMT60- Twitter法面试题详解(Java实现Q?/title>http://www.aygfsteel.com/nokiaguy/archive/2013/11/03/405944.html银河使?/dc:creator>银河使?/author>Sun, 03 Nov 2013 10:03:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2013/11/03/405944.htmlhttp://www.aygfsteel.com/nokiaguy/comments/405944.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2013/11/03/405944.html#Feedback0http://www.aygfsteel.com/nokiaguy/comments/commentRss/405944.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/405944.html阅读全文

]]> - 癑ֺ面试题:求绝对值最的?/title>http://www.aygfsteel.com/nokiaguy/archive/2013/01/30/394920.html银河使?/dc:creator>银河使?/author>Wed, 30 Jan 2013 03:45:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2013/01/30/394920.htmlhttp://www.aygfsteel.com/nokiaguy/comments/394920.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2013/01/30/394920.html#Feedback6http://www.aygfsteel.com/nokiaguy/comments/commentRss/394920.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/394920.html 有一个已l排序的数组Q升序)Q数l中可能有正数、负数或0Q求数组中元素的l对值最的敎ͼ要求Q不能用序比较的方法(复杂度需要小于OQnQ)Q可以用Q何语a实现
例如Q数l{-20Q?13Q?4, 6, 77,200} Q绝对值最的?4?/p>
法实现的基本思\
扑ֈ负数和正数的分界点,如果正好?是它了Q如果是正数Q再和左面相ȝ负数l对值比较,如果是负敎ͼ取取l对g右面正数比较。还要考虑数组只有正数或负数的情况?/p>
我根据这个思\用Java单实C一个算法?span style="color: #ff0000;">大家有更好的实现ҎƢ迎跟帖
public class MinAbsoluteValue
{
private static int getMinAbsoluteValue(int[] source)
{
int index = 0;
int result = 0;
int startIndex = 0;
int endIndex = source.length - 1;
// 计算负数和正数分界点
while(true)
{ // 计算当前的烦?/span>
index = startIndex + (endIndex - startIndex) / 2;
result = source[index];<br> // 如果{于0Q就直接q回了,0肯定是绝对值最的
if(result==0)
{
return 0;
} // 如果值大?Q处理当前位|左侧区域,因ؓ负数肯定在左?/span>
else if(result > 0)
{
if(index == 0)
{
break;
}
if(source[index-1] >0)
endIndex = index - 1;
else if(source[index-1] ==0)
return 0;
else
break;
} // 如果于0Q处理当前位|右侧的区域Q因为正数肯定在右侧的位|?/span>
else
{
if(index == endIndex)
break;
if(source[index + 1] < 0)
startIndex = index + 1;
else if(source[index + 1] == 0)
return 0;
else
break;
}
}
// Ҏ分界点计绝对值最的?/span>
if(source[index] > 0)
{
if(index == 0 || source[index] < Math.abs(source[index-1]))
result= source[index];
else
result = source[index-1];
}
else
{
if(index == source.length - 1 || Math.abs(source[index]) < source[index+1])
result= source[index];
else
result = source[index+1];
}
return result;
}
public static void main(String[] args) throws Exception
{
int[] arr1 = new int[]{-23,-22,-3,-2,1,2,3,5,20,120};
int[] arr2 = new int[]{-23,-22,-12,-6,-4};
int[] arr3 = new int[]{1,22,33,55,66,333};
int value = getMinAbsoluteValue(arr1);
System.out.println(value);
value = getMinAbsoluteValue(arr2);
System.out.println(value);
value = getMinAbsoluteValue(arr3);
System.out.println(value);
}
}

]]>- 不用中间变量交换两个数QJava版)http://www.aygfsteel.com/nokiaguy/archive/2010/07/28/327291.html银河使?/dc:creator>银河使?/author>Wed, 28 Jul 2010 02:29:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2010/07/28/327291.htmlhttp://www.aygfsteel.com/nokiaguy/comments/327291.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2010/07/28/327291.html#Feedback8http://www.aygfsteel.com/nokiaguy/comments/commentRss/327291.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/327291.html阅读全文

]]> - 有道N2009复赛题解{(Java版)Q求大于l定数的最不重复?/title>http://www.aygfsteel.com/nokiaguy/archive/2010/05/11/320597.html银河使?/dc:creator>银河使?/author>Tue, 11 May 2010 08:23:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2010/05/11/320597.htmlhttp://www.aygfsteel.com/nokiaguy/comments/320597.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2010/05/11/320597.html#Feedback21http://www.aygfsteel.com/nokiaguy/comments/commentRss/320597.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/320597.html阅读全文

]]> - 生成n*n蛇Ş矩阵的算?/title>http://www.aygfsteel.com/nokiaguy/archive/2009/07/24/288163.html银河使?/dc:creator>银河使?/author>Fri, 24 Jul 2009 03:04:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2009/07/24/288163.htmlhttp://www.aygfsteel.com/nokiaguy/comments/288163.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2009/07/24/288163.html#Feedback7http://www.aygfsteel.com/nokiaguy/comments/commentRss/288163.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/288163.html
1 3 4 10 11
2 5 9 12 19
6 8 13 18 20
7 14 17 21 24
15 16 22 23 25
上面的表格很Ҏ看出规律。就是从左上角第一个格开始(起始?Q,然后延右上角到左下角的斜Uѝ先从下CQ再从上C。开始按数字递增排列。也是说每一个斜U上分别有如下几l数字:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 阅读全文
]]> - Base64~码原理与实?/title>http://www.aygfsteel.com/nokiaguy/archive/2009/05/29/278938.html银河使?/dc:creator>银河使?/author>Fri, 29 May 2009 11:20:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2009/05/29/278938.htmlhttp://www.aygfsteel.com/nokiaguy/comments/278938.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2009/05/29/278938.html#Feedback0http://www.aygfsteel.com/nokiaguy/comments/commentRss/278938.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/278938.html阅读全文

]]> - 09考研数据l构试题的一U解法(Java版)http://www.aygfsteel.com/nokiaguy/archive/2009/01/17/251722.html银河使?/dc:creator>银河使?/author>Sat, 17 Jan 2009 12:50:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2009/01/17/251722.htmlhttp://www.aygfsteel.com/nokiaguy/comments/251722.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2009/01/17/251722.html#Feedback7http://www.aygfsteel.com/nokiaguy/comments/commentRss/251722.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/251722.html阅读全文

]]> - 选择排序(selection sort)法实现http://www.aygfsteel.com/nokiaguy/archive/2008/05/16/200878.html银河使?/dc:creator>银河使?/author>Fri, 16 May 2008 05:21:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/16/200878.htmlhttp://www.aygfsteel.com/nokiaguy/comments/200878.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/16/200878.html#Feedback0http://www.aygfsteel.com/nokiaguy/comments/commentRss/200878.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/200878.html阅读全文

]]> - 希尔排序(shellsort)法实现http://www.aygfsteel.com/nokiaguy/archive/2008/05/15/200734.html银河使?/dc:creator>银河使?/author>Thu, 15 May 2008 14:01:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/15/200734.htmlhttp://www.aygfsteel.com/nokiaguy/comments/200734.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/15/200734.html#Feedback1http://www.aygfsteel.com/nokiaguy/comments/commentRss/200734.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/200734.html阅读全文

]]> - 快速排?quicksort)法实现http://www.aygfsteel.com/nokiaguy/archive/2008/05/14/200471.html银河使?/dc:creator>银河使?/author>Wed, 14 May 2008 12:14:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/14/200471.htmlhttp://www.aygfsteel.com/nokiaguy/comments/200471.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/14/200471.html#Feedback0http://www.aygfsteel.com/nokiaguy/comments/commentRss/200471.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/200471.html 阅读全文

]]> - 得到WK个大的数法研究http://www.aygfsteel.com/nokiaguy/archive/2008/05/12/200083.html银河使?/dc:creator>银河使?/author>Mon, 12 May 2008 12:55:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/12/200083.htmlhttp://www.aygfsteel.com/nokiaguy/comments/200083.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/12/200083.html#Feedback0http://www.aygfsteel.com/nokiaguy/comments/commentRss/200083.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/200083.html阅读全文

]]> - 盘覆盖问题的算法实?/title>http://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199893.html银河使?/dc:creator>银河使?/author>Sun, 11 May 2008 14:29:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199893.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199893.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199893.html#Feedback1http://www.aygfsteel.com/nokiaguy/comments/commentRss/199893.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199893.html阅读全文

]]> - 拆半查找的递归和非递归法http://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199892.html银河使?/dc:creator>银河使?/author>Sun, 11 May 2008 14:26:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199892.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199892.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199892.html#Feedback4http://www.aygfsteel.com/nokiaguy/comments/commentRss/199892.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199892.html阅读全文

]]> - 全排列算法原理和实现http://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199838.html银河使?/dc:creator>银河使?/author>Sun, 11 May 2008 07:43:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199838.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199838.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199838.html#Feedback11http://www.aygfsteel.com/nokiaguy/comments/commentRss/199838.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199838.html例说明如何编写全排列的递归法? 阅读全文

]]> - 整数划分法原理与实?/title>http://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199837.html银河使?/dc:creator>银河使?/author>Sun, 11 May 2008 07:41:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199837.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199837.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/11/199837.html#Feedback0http://www.aygfsteel.com/nokiaguy/comments/commentRss/199837.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199837.html阅读全文

]]> - 《程序员》第9期智慧擂台题目——高频词汇提?/title>http://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199654.html银河使?/dc:creator>银河使?/author>Sat, 10 May 2008 01:37:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199654.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199654.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199654.html#Feedback1http://www.aygfsteel.com/nokiaguy/comments/commentRss/199654.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199654.html阅读全文

]]> - 癑ֺ面试题的java实现http://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199649.html银河使?/dc:creator>银河使?/author>Sat, 10 May 2008 01:23:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199649.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199649.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199649.html#Feedback10http://www.aygfsteel.com/nokiaguy/comments/commentRss/199649.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199649.html阅读全文

]]> - 一著名软g公司的javaW试法题的{案http://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199647.html银河使?/dc:creator>银河使?/author>Sat, 10 May 2008 01:19:00 GMThttp://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199647.htmlhttp://www.aygfsteel.com/nokiaguy/comments/199647.htmlhttp://www.aygfsteel.com/nokiaguy/archive/2008/05/10/199647.html#Feedback11http://www.aygfsteel.com/nokiaguy/comments/commentRss/199647.htmlhttp://www.aygfsteel.com/nokiaguy/services/trackbacks/199647.html阅读全文

]]>
վ֩ģ壺
|
ʼ|
|
|
˫|
ܱ|
|
³|
˫|
|
ͨμ|
|
ղ|
|
Ž|
|
|
|
ʲ|
|
|
¤|
˰|
|
ױ|
|
ͤ|
|
½|
|
|
|
|
|
½|
ɽ|
|
|
٤ʦ|
ԭƽ|
|