HW7.7
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的更多相关文章
- HW7.18
public class Solution { public static void main(String[] args) { int[][] m = {{1, 2}, {3, 4}, {5, 6} ...
- HW7.17
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.16
import java.util.Arrays; public class Solution { public static void main(String[] args) { int row = ...
- HW7.15
public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, ...
- HW7.14
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.13
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.12
import java.util.Scanner; public class Solution { public static void main(String[] args) { double[] ...
- HW7.11
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.10
public class Solution { public static void main(String[] args) { int[][] array = new int[3][3]; for( ...
- HW7.9
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- 免费素材:25套免费的 Web UI 设计的界面元素(转)
Web 元素是任何网站相关项目都需要的,质量和良好设计的元素对于设计师来说就像宝贝一样.如果您正在为您的网站,博客,Web 应用程序或移动应用程序寻找完美设计的网页元素,那么下面这个列表会是你需要的. ...
- [Firefly引擎][学习笔记四][已完结]服务器端与客户端的通讯
原地址:http://www.9miao.com/question-15-54981.html 传送门:学习笔记一学习笔记二学习笔记三 前言:学习笔记三是模块封装,这个在持续开发中会不断更新, 因为写 ...
- vc2008程序发布指南
vc2008程序发布指南 2008-05-03 17:46 vc2008开发的程序的发布方式可以有5种方式: 1. 采用静态链接到crt和MFC. 只要你拥有组成程序的所有源代码,你就可以采用这种方式 ...
- POJ 3792 Area of Polycubes(思维)
点我看题目 题意 : 其实我也说不太清楚题意,就是给你很多方块,每放一块方块,都要和前一块有一个面相接,如果不相接,就输出NO,并输出是第几个方块不相接的.如果满足每一个都和前边相接,那就判断所有没有 ...
- 版本管理工具介绍—Git篇
前篇 如题,提起版本管理工具相信做C#开发 还是对Git比较陌生 我们可能更熟悉vss.svn 记录此文的目的 更是为以后的前段学习做基础 现在的技术比如nodeJs angularJs ==都 ...
- SaaS系列介绍之二: SaaS介绍
1 引言 横看成岭侧成峰,远近高低各不同. 不识庐山真面目, 只缘身在此山中. ________苏轼, ...
- 64位ubuntu安装WPS
http://jingyan.baidu.com/article/d3b74d64afd96f1f77e609a3.html http://sixipiaoyang.blog.163.com/blog ...
- C++创建一个动态链接库工程
前话 在我们安装一些软件时,进入软件安装目录会经常看到.dll格式文件,系统system目录也存在许多dll文件 在软件游戏(window平台)更新的时候,很大部分是下载dll文件 所以会好奇这是什么 ...
- Android:控件布局(单帧布局)FrameLayout
FrameLayout:所有控件位于左上角,并且直接覆盖前面的子元素. 在最上方显示的层加上: android:clickable="true" 可以避免点击上层触发底层. 实例: ...
- 判断浏览器类型-----------navigator.userAgent.indexOf()
<script language="JavaScript"> <!-- function getOs() { var OsObject = "" ...