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. DWR

    DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站.它可以允许在浏览器里的代码使用运行在 ...

  2. [Firefly引擎][学习笔记三][已完结]所需模块封装

    原地址:http://www.9miao.com/question-15-54671.html 学习笔记一传送门学习笔记二传送门 学习笔记三导读:        笔记三主要就是各个模块的封装了,这里贴 ...

  3. Zookeeper实战之单机集群模式

    前一篇文章介绍了Zookeeper的单机模式的安装及应用,但是Zookeeper是为了解决分布式应用场景的,所以通常都会运行在集群模式下.今天由于手头机器不足,所以今天打算在一台机器上部署三个Zook ...

  4. [Unity菜鸟] 术语

    HUD Mozilla  Mozilla基金会,简称Mozilla(缩写MF或MoFo),是为支持和领导开源的Mozilla项目而设立的一个非营利组织. 称作Mozilla公司的子公司,雇佣了一些Mo ...

  5. Qt之QtSoap(访问WebService)

    http://blog.csdn.net/u011012932/article/details/51673800

  6. 179. Largest Number

    题目: Given a list of non negative integers, arrange them such that they form the largest number. For ...

  7. Move to Another Changelist

    Move to Another Changelist 将选中的文件转移到其他的 Change list 中. Change list 是一个重要的概念,这里需要进行重点说明.很多时候,我们开发一个项目 ...

  8. 关于rewriteRule的一个小问题

    RewriteEngine on # RewriteRule ^test.php$ modrewrite.php# RewriteRule ^(.*) http://www.baidu.com [L] ...

  9. java 死锁及解决

    Java线程死锁如何避免这一悲剧  Java线程死锁需要如何解决,这个问题一直在我们不断的使用中需要只有不断的关键.不幸的是,使用上锁会带来其他问题.让我们来看一些常见问题以及相应的解决方法: Jav ...

  10. poj 2251 Dungeon Master( bfs )

    题目:http://poj.org/problem?id=2251 简单三维 bfs不解释, 1A,     上代码 #include <iostream> #include<cst ...