Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TamGiac() {
- public static void main(String[] args) {
- int a,b,c;
- Scanner sc = new Scanner(System.in);
- System.out.println("Nhap a, b, c");
- System.out.print("a = ");
- a = sc.nextInt();
- System.out.print("b = ");
- b = sc.nextInt();
- System.out.print("c = ");
- c = sc.nextInt();
- //kiem tra tam giac
- if(a+b > c && a+c > b && b+c > a && a > 0 && b > 0 && c > 0) {
- // neu thoa man la 3 canh cua 1 tam giac thi bat dau kiem tra truong hop dac biet
- if(a == b && b == c && c == a) {
- System.out.println("Tam giác đều");
- }else if(a==b || b == c || c == a) {
- System.out.println("Tam giác cân");
- }else if(a*a + b*b == c*c || a*a + c*c == b*b || c*c + b*b == a*a) {
- System.out.println("Tam giác vuông");
- }else {
- System.out.println("Tam giác thường");
- }
- } else {
- // neu khong thoa man
- System.out.println("Đó không phải 3 cạnh tam giác");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement