Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Khuzha/06db272c2cad3f12037e653a1ee869b6 to your computer and use it in GitHub Desktop.
Save Khuzha/06db272c2cad3f12037e653a1ee869b6 to your computer and use it in GitHub Desktop.
package com.khuzha.objects;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Введите длину стороны а:");
float a = scan.nextInt();
System.out.println("Введите длину стороны b:");
float b = scan.nextInt();
System.out.println("Введите длину стороны с:");
float c = scan.nextInt();
if (a + b < c || a + c < b || b + c < a) {
System.out.println("Такого треугольника не существует.");
return;
}
float p = (float) (0.5 * (a + b + c));
float s = (float) (p * (p - a) * (p - b) * (p - c));
float h = (float) (2 * Math.sqrt(s) / a);
System.out.println("Высоты, опущенная на сторону а, равна " + h);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment