hypotenuse.java
来自「java版的数据结构的完全代码 免费提供了 学习数据结构的请下载」· Java 代码 · 共 27 行
JAVA
27 行
// Introduced in Chapter 4/** Compute the hypotenuse of a right triangle. */public class Hypotenuse { /** Return the square of the number x. */ public static double square(double x) { return x * x; } /** * Return the hypotenuse of a right triangle with side lengths x * and y. */ public static double hypotenuse(double x, double y) { double x2 = square(x); double y2 = square(y); return Math.sqrt(x2 + y2); } /** Test the methods. */ public static void main(String[] args) { double result = hypotenuse(3, 4); System.out.println(result); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?