Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 21, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/73aa7834b25ad67dacd273c0ef2da0b7 to your computer and use it in GitHub Desktop.
Save peter279k/73aa7834b25ad67dacd273c0ef2da0b7 to your computer and use it in GitHub Desktop.
TQC+ JAVA
import java.util.Scanner;
public class JPA01 {
public static void main(String []args) {
Scanner input = new Scanner(System.in);
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