返回列表 發帖
  1. import java.util.Scanner;


  2. public class JPA01 {
  3.          static Scanner keyboard = new Scanner(System.in);
  4.             public static void main(String[] args) {
  5.                 test();        
  6.                 test();
  7.                 test();
  8.                 test();
  9.             }
  10.             
  11.             static void test() {
  12.             System.out.print("請輸入三個整數:")   ;
  13.             int a=keyboard.nextInt();
  14.             int b=keyboard.nextInt();
  15.             int c=keyboard.nextInt();
  16.             if(a+b>c&&c+b>a&&a+c>b&&a!=0&b!=0&&c!=0)
  17.             {
  18.             if(a*a+b*b==c*c||c*c+b*b==a*a||a*a+c*c==b*b)
  19.             {
  20.                      System.out.println("直角三角形")   ;       
  21.             }
  22.             else if(a*a+b*b<c*c||c*c+b*b<a*a||a*a+c*c<b*b)
  23.             {
  24.                      System.out.println("頓角三角形")   ;       
  25.             }
  26.             else
  27.             {
  28.                      System.out.println("銳角三角形")   ;       
  29.             }
  30.             }
  31.             else
  32.             {
  33.                     System.out.println("不可以構成三角形")   ;       
  34.             }
  35.             }
  36.         }
複製代碼

TOP

返回列表