Created
May 24, 2017 04:58
-
-
Save peter279k/9271f3b842199d861cf4134127e09e87 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.*; | |
public class JPA02 { | |
static Scanner keyboard = new Scanner(System.in); | |
public static void main(String[] args) { | |
test(); | |
test(); | |
test(); | |
test(); | |
} | |
static void test() { | |
System.out.print("請輸入三個整數: "); | |
int a = keyboard.nextInt(); | |
int b = keyboard.nextInt(); | |
int c = keyboard.nextInt(); | |
if(a <= 0 || b<=0 || c <= 0) { | |
System.out.println("不可以構成三角形"); | |
} else if(a + b > c && b + c > a && a + c > b) { | |
if((a * a + b * b) == c * c || (b * b + c * c) == a * a || (a * a + c * c) == b * b) { | |
System.out.println("直角三角形"); | |
} | |
if((a * a + b * b) < c * c || (b * b + c * c) < a * a || (a * a + c * c) < b * b) { | |
System.out.println("鈍角三角形"); | |
} | |
if((a * a + b * b) > c * c && (b * b + c * c) > a * a && (a * a + c * c) > b * b) { | |
System.out.println("銳角三角形"); | |
} | |
} else { | |
System.out.println("不可以構成三角形"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment