求数对的最大值
摘要:
package maxD_value;/*** 题目:在数组中,数字减去它右边的数字得到一个数对之差。* 求所有数对之差的最大值。例如在数组{2, 4, 1, 16, 7, 5, 11, 9}中,数对之差的最大值是11,是16减去5的结果。**/public class Test {//下面这个方法是从后往前遍历一遍,找出最小的值,然后用前面的值减去最小的值,并找出遍历中的最大数,则得到了结果。public static int maxValue_MethodOne(int array[]){int max=0,D_value;int n = array.length;int min = ar 阅读全文
posted @ 2012-03-17 23:43 c语言源码 阅读(291) 评论(0) 推荐(0) 编辑