Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/
Created May 21, 2017

What would you like to do?
import java.util.Scanner;
public class JPA01 {
public static void main(String []args) {
Scanner input = new Scanner(;
System.out.print("輸入第1 組x和y座標:");
int x1 = input.nextInt();
int y1 = input.nextInt();
System.out.print("輸入第2 組x和y座標:");
int x2 = input.nextInt();
int y2 = input.nextInt();
double res = Math.pow(Math.abs(x2 - x1), 2) + Math.pow(Math.abs(y2 - y1), 2);
res = Math.sqrt(res);
System.out.printf("介於(%d,%d)和(%d,%d)之間的距離是%.2f\r\n", x1, y1, x2, y2, res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.