算法 第四版 1.4.16

来源:互联网 发布:乐高 t r3x 编程下载 编辑:程序博客网 时间:2024/05/22 01:53
public static double Pro1_4_16(double[] a){double[] temp = a.clone();for(int i=0;i<temp.length;i++)if(temp[i]<0) temp[i]=-temp[i];Arrays.sort(temp);double ans = Double.MAX_VALUE;for(int i=1;i<temp.length;i++)ans=Math.min(ans, temp[i]-temp[i-1]);return ans;}

原创粉丝点击