public class Solution
 {
     public static void main(String[] args)
     {
         double[][] points =
         {
             {-1, 0, 3}, {-1, -1, -1},
             {4, 1, 1}, {2, 0.5, 9},
             {3.5, 2, -1}, {3, 1.5, 3},
             {-1.5, 4, 2}, {5.5, 4, -0.5}
         };

         double shortestDistance = distance(points[0][0], points[0][1], points[0][2],
             points[1][0], points[1][1], points[1][2]);
         double currentDistance = shortestDistance;

         for(int i = 0; i < points.length; i++)
         {
             for(int j = i + 1; j < points.length; j++)
             {
                 currentDistance = distance(points[i][0], points[i][1], points[i][2],
                     points[j][0], points[j][1], points[j][2]);
                 if(currentDistance < shortestDistance)
                     shortestDistance = currentDistance;
             }
         }

         System.out.println("The shortest distance is " + shortestDistance);
     }

     public static double distance(double x1, double y1, double z1, double x2, double y2, double z2)
     {
         double square = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1);
         return Math.sqrt(square);
     }
 }

HW7.7的更多相关文章

  1. HW7.18

    public class Solution { public static void main(String[] args) { int[][] m = {{1, 2}, {3, 4}, {5, 6} ...

  2. HW7.17

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. HW7.16

    import java.util.Arrays; public class Solution { public static void main(String[] args) { int row = ...

  4. HW7.15

    public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, ...

  5. HW7.14

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW7.13

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW7.12

    import java.util.Scanner; public class Solution { public static void main(String[] args) { double[] ...

  8. HW7.11

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  9. HW7.10

    public class Solution { public static void main(String[] args) { int[][] array = new int[3][3]; for( ...

  10. HW7.9

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. ASP + ACCESS 上传图片到数据库与将图片读出数据库显示之实现

    1.uppic.asp:上传图片程序 <% dim rs dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata formsi ...

  2. 关于NGUI中的自适应和对齐机制

    原地址:http://blog.sina.com.cn/s/blog_62df69790101gy7t.html 1 关于美术效果图 美术出效果图总是基于某个固定尺寸.移动设备的分辨率却有太多不同的方 ...

  3. js获取fck值的代码方法

    引入js文件 <script type="text/javascript" src="${basePath}/FCKeditor/fckeditor.js" ...

  4. Docker 监控实战

    如今,越来越多的公司开始使用 Docker 了,现在来给大家看几组数据: 2 / 3 的公司在尝试了 Docker 后最终使用了它 也就是说 Docker 的转化率达到了 67%,而转化市场也控制在 ...

  5. QueryPerformanceFrequency 和 QueryPerformanceCounter用法

    QueryPerformanceFrequency() - 基本介绍 类型:Win32API 原型:BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFr ...

  6. VC中支持中文的字符串比较函数

    VS2008开发环境,多字符集和UNICODE字符集都可用. WCHAR * mbcsToUnicode(const char *zStr) { int nByte; WCHAR *zMbcsStr; ...

  7. 敏捷开发系列之旅 第二站(走近XP极限编程)

    http://blog.csdn.net/happylee6688/article/details/21551065 上篇文章,我们探讨了什么是敏捷开发,以及敏捷开发的方法学.在这篇文章中,我们将继续 ...

  8. 如何解决MySQLAdministrator 启动报错

    运行环境:MySQL 5.1.41 win32 ZIP 非安装版MySQL GUI Tools 5.0(版本1.2.17.0) 运行MySQLAdministrator时提示:服务器服务或配置文件不能 ...

  9. 大四实习准备1_java构造器_android ListView

    2015-4-23 Java构造器 与类名同名;无返回值(void也不行);被不同的修饰符修饰是有区别的;当构造函数被private修饰时,只有本类可访问.其他类可以通过该类的get函数得到对象.如单 ...

  10. Eclipse环境下JBoss调试,解决引用的工程不被部署的问题

    其实算是一个很小的经验,在eclipse环境下进行jboss的部署,因为要定义某公共包的问题,将代码down下来做了个工程,部署时发现jboss提示:class not found! 从jboss部署 ...