Created
May 21, 2017 16:21
-
-
Save peter279k/73aa7834b25ad67dacd273c0ef2da0b7 to your computer and use it in GitHub Desktop.
TQC+ JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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