Advertisement
nqchung

TamGiac

May 18th, 2020
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.93 KB | None | 0 0
  1. public class TamGiac() {
  2.     public static void main(String[] args) {
  3.         int a,b,c;
  4.         Scanner sc = new Scanner(System.in);
  5.         System.out.println("Nhap a, b, c");
  6.         System.out.print("a = ");
  7.         a = sc.nextInt();
  8.         System.out.print("b = ");
  9.         b = sc.nextInt();
  10.         System.out.print("c = ");
  11.         c = sc.nextInt();
  12.         //kiem tra tam giac
  13.         if(a+b > c && a+c > b && b+c > a && a > 0 && b > 0 && c > 0) {
  14.             // neu thoa man la 3 canh cua 1 tam giac thi bat dau kiem tra truong hop dac biet
  15.             if(a == b && b == c && c == a) {
  16.                 System.out.println("Tam giác đều");
  17.             }else if(a==b || b == c || c == a) {
  18.                 System.out.println("Tam giác cân");
  19.             }else if(a*a + b*b == c*c || a*a + c*c == b*b || c*c + b*b == a*a) {
  20.                 System.out.println("Tam giác vuông");
  21.             }else {
  22.                 System.out.println("Tam giác thường");
  23.             }
  24.         } else {
  25.             // neu khong thoa man
  26.             System.out.println("Đó không phải 3 cạnh tam giác");
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement