Данный отчёт сгенерирован 04.04.2023 06:21:13 UTC.
HTML версия (этот сайт) сгенерирован 04.04.2023 06:21:31 UTC.
Коммит: [bfeb65b9] add automatic zip creation 04.04.2023 06:21:13
HTML версия (этот сайт) сгенерирован 04.04.2023 06:21:31 UTC.
Коммит: [bfeb65b9] add automatic zip creation 04.04.2023 06:21:13
Задача: Трикутник
04.04.2023 06:21:13
Описание: Оголосити статичний метод double Square(double a, double b, double c), який повертає площу трикутника зі сторонами a, b та c. Якщо трикутник не можна побудувати, метод викидає виняток NotTriangleException.
04.04.2023 06:21:13
Решений: 27
04.04.2023 06:21:13
Трикутник
04.04.2023 06:21:13
class NotTriangleException : Exception
{
public NotTriangleException()
{
}
public NotTriangleException(string message) : base(message)
{
}
}
static double Square(double a, double b, double c)
{
if(a <= 0 || b <= 0 || c <= 0)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt( p * (p - a) * (p - b) * (p - c));
}
[Serializable]
public class NotTriangleException : Exception
{
public NotTriangleException() { }
public NotTriangleException(string message) : base(message) { }
public NotTriangleException(string message, Exception inner) : base(message, inner) { }
protected NotTriangleException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
static double Square(double a, double b, double c)
{
if(a + b > c &&
b + c > a &&
c + a > b)
{
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
throw new NotTriangleException("Triangle with such side lengths does not exist");
}
class NotTriangleException: Exception
{
public NotTriangleException() { }
public NotTriangleException(string message)
: base(message) { }
public NotTriangleException(string message, Exception inner)
: base(message, inner) { }
}
static double Square(double a, double b, double c)
{
if (NotTriangle(a, b, c)) {
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static bool NotTriangle(double a, double b, double c)
{
return !(a < b + c && b < a + c && c < b + c);
}
class NotTriangleException : Exception {}
public static double Square(double a, double b, double c)
{
if (!IsValidTriangle(a, b ,c))
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public static bool IsValidTriangle(double a, double b, double c) => c < a + b && b < a + c && a < b + c;
class NotTriangleException : Exception { }
static double Square(double a, double b, double c)
{
if (!(a + b > c || a + c > b || b + c > a))
throw new NotTriangleException();
var p = (a + b + c) / 2;
var s = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
return s;
}
class NotTriangleException : Exception
{
public NotTriangleException()
: base() { }
}
static double Square(double a, double b, double c)
{
if (a + b <= c || a + c <= b ||b + c <= a)
throw new NotTriangleException();
else{
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
}
class NotTriangleException : Exception
{
}
static double Square(double a, double b, double c) {
if(a <= 0 || b <= 0 || c <= 0)
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public class NotTriangleException : Exception
{
public NotTriangleException()
{
}
public NotTriangleException(string message)
: base(message)
{
}
public NotTriangleException(string message, Exception inner)
: base(message, inner)
{
}
}
static double Square(double a, double b, double c)
{
try
{
double p = (a + b + c) / 2;
double S = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
return S;
}
catch (Exception)
{
throw new NotTriangleException();
}
}
class NotTriangleException : Exception { }
static double Square(double a, double b, double c)
{
if(a+b < c || a+c < b || b+c < a)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static double Square(double a, double b, double c)
{
if (a + b <= c || a + c <= b || b + c <= a)
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
internal class NotTriangleException : Exception
{
public NotTriangleException()
{
}
public NotTriangleException(string? message) : base(message)
{
}
public NotTriangleException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
internal class NotTriangleException : Exception
{
public NotTriangleException()
{
Console.WriteLine("Error");
}
public NotTriangleException(string? message) : base(message)
{
Console.WriteLine("Error");
}
}
static double Square(double a, double b, double c)
{
if(a + b < c || a+c < b || b+c < a )
{
throw new NotTriangleException();
}
return Math.Sqrt((a+b+c)*(a+b+c-a)*(a+b+c-b)*(a+b+c-c));
}
public class NotTriangleException : Exception
{
public NotTriangleException()
:base()
{}
}
static double Square(double a, double b, double c)
{
if (a + b <= c || a + c <= b || b + c <= a)
throw new NotTriangleException();
var halfP = (a + b + c) / 2;
return Math.Sqrt(halfP * (halfP - a) * (halfP - b) * (halfP - c));
}
public class NotTriangleException : Exception
{
public NotTriangleException()
: base("The triangle is not right")
{ }
}
static double Square(double a, double b, double c)
{
if (Math.Abs(a-b) > c || a+b < c)
throw new NotTriangleException();
var p = (a+b+c) / 2;
return Math.Sqrt(p * (p-a) * (p-b) * (p-c));
}
class NotTriangleException : Exception
{
public NotTriangleException(Exception innerException)
: base("", innerException)
{
}
}
static double Square(double a, double b, double c)
{
bool aCriteria = a < b + c;
bool bCriteria = b < a + c;
bool cCriteria = c < b + a;
if (!aCriteria || !bCriteria || !cCriteria)
{
throw new NotTriangleException(new ArgumentException());
}
double p = a + b + c;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static double Square(double a, double b, double c)
{
if (a + b < c || b + c < a || a + c < b)
throw new NotTriangleException();
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public class NotTriangleException : Exception { }
class NotTriangleException : Exception {}
static double Square(double a, double b, double c)
{
if (a + b < c || a + c < b || b + c < a)
throw new NotTriangleException();
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
class NotTriangleException : Exception { }
static double Square(double a, double b, double c)
{
if(a+b < c || a+c < b || b+c < a)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static double Square(double a, double b, double c)
{
if (a + b < c ||
a + c < b ||
b + c < a) throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
class NotTriangleException : Exception { }
public class NotTriangleException : Exception
{
}
static double Square(double a, double b, double c)
{
if(a < b + c && b < a + c && c < a + b)
{
return Math.Pow((a + b + c) * (b + c - a) * (a + c - b) * (a + b - c), 0.5) * 0.25;
}
throw new NotTriangleException();
}
internal class NotTriangleException : Exception {
public NotTriangleException(string message) : base(message) { }
}
static double Square(double a, double b, double c) {
if(!(a + b > c && a + c > b && b + c > a))
throw new NotTriangleException("Не трикутник");
double p = (a+b+c)/2;
return Math.Sqrt(p*(p-a)*(p-b)*(p-c));
}
class NotTriangleException : Exception {}
static double Square(double a, double b, double c)
{
if (a + b < c || a + c < b || b + c < a)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static double Square(double a, double b, double c)
{
if (a + b < c || a + c < b || b + c < a) throw new NotTriangleException();
double semiperimeter = (a + b + c) / 2;
return Math.Sqrt(semiperimeter * (semiperimeter - a) * (semiperimeter - b) * (semiperimeter - c));
}
class NotTriangleException : Exception
{
public NotTriangleException() : base("")
{ }
}
class NotTriangleException : Exception
{
public NotTriangleException()
: base("There is no triangle with such sides.")
{ }
}
static double Square(double a, double b, double c)
{
if (!(c < a + b && b < a + c && a < b + c))
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
class NotTriangleException : Exception
{
public NotTriangleException() :base(){}
}
static void CheckIfTraingle(double a, double b, double c)
{
if((a+b) < c || (a+c) < b || (b+c) < a)
throw new NotTriangleException();
}
public static double Square(double a, double b, double c)
{
CheckIfTraingle(a,b,c);
double p = (a + b + c) / 2;
return Math.Sqrt(p*(p - a) + p*(p -b) + p*(p - c));
}
class NotTriangleException : Exception
{
}
static double Square(double a, double b, double c)
{
return a + b > c || a + c > b || c + b > a ?
Math.Pow(((a + b + c) / 3) * (((a + b + c) / 3) - a) * (((a + b + c) / 3) - b) * (((a + b + c) / 3) - c), 0.5)
: throw new NotTriangleException();
}
class NotTriangleException : Exception {}
public static double Square(double a, double b, double c) {
if (a + b > c && a + c > b && b + c > a)
return Math.Sqrt((a + b + c) * (b + c) * (c + a) * (a + b));
else
throw new NotTriangleException();
}
class NotTriangleException:Exception{
public NotTriangleException():base(){}
}
static double Square(double a, double b, double c) {
if(a+b<=c ||a+c<=b || b+c<=a)
throw new NotTriangleException();
double p=(a+b+c)/2;
return Math.Sqrt(p*(p - a)*(p - b)*(p - c));
}
{
public NotTriangleException()
{
}
public NotTriangleException(string message) : base(message)
{
}
}
static double Square(double a, double b, double c)
{
if(a <= 0 || b <= 0 || c <= 0)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt( p * (p - a) * (p - b) * (p - c));
}
public class NotTriangleException : Exception
{
public NotTriangleException() { }
public NotTriangleException(string message) : base(message) { }
public NotTriangleException(string message, Exception inner) : base(message, inner) { }
protected NotTriangleException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
static double Square(double a, double b, double c)
{
if(a + b > c &&
b + c > a &&
c + a > b)
{
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
throw new NotTriangleException("Triangle with such side lengths does not exist");
}
{
public NotTriangleException() { }
public NotTriangleException(string message)
: base(message) { }
public NotTriangleException(string message, Exception inner)
: base(message, inner) { }
}
static double Square(double a, double b, double c)
{
if (NotTriangle(a, b, c)) {
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static bool NotTriangle(double a, double b, double c)
{
return !(a < b + c && b < a + c && c < b + c);
}
public static double Square(double a, double b, double c)
{
if (!IsValidTriangle(a, b ,c))
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public static bool IsValidTriangle(double a, double b, double c) => c < a + b && b < a + c && a < b + c;
static double Square(double a, double b, double c)
{
if (!(a + b > c || a + c > b || b + c > a))
throw new NotTriangleException();
var p = (a + b + c) / 2;
var s = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
return s;
}
{
public NotTriangleException()
: base() { }
}
static double Square(double a, double b, double c)
{
if (a + b <= c || a + c <= b ||b + c <= a)
throw new NotTriangleException();
else{
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
}
{
}
static double Square(double a, double b, double c) {
if(a <= 0 || b <= 0 || c <= 0)
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
{
public NotTriangleException()
{
}
public NotTriangleException(string message)
: base(message)
{
}
public NotTriangleException(string message, Exception inner)
: base(message, inner)
{
}
}
static double Square(double a, double b, double c)
{
try
{
double p = (a + b + c) / 2;
double S = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
return S;
}
catch (Exception)
{
throw new NotTriangleException();
}
}
static double Square(double a, double b, double c)
{
if(a+b < c || a+c < b || b+c < a)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
{
if (a + b <= c || a + c <= b || b + c <= a)
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
internal class NotTriangleException : Exception
{
public NotTriangleException()
{
}
public NotTriangleException(string? message) : base(message)
{
}
public NotTriangleException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
{
public NotTriangleException()
{
Console.WriteLine("Error");
}
public NotTriangleException(string? message) : base(message)
{
Console.WriteLine("Error");
}
}
static double Square(double a, double b, double c)
{
if(a + b < c || a+c < b || b+c < a )
{
throw new NotTriangleException();
}
return Math.Sqrt((a+b+c)*(a+b+c-a)*(a+b+c-b)*(a+b+c-c));
}
{
public NotTriangleException()
:base()
{}
}
static double Square(double a, double b, double c)
{
if (a + b <= c || a + c <= b || b + c <= a)
throw new NotTriangleException();
var halfP = (a + b + c) / 2;
return Math.Sqrt(halfP * (halfP - a) * (halfP - b) * (halfP - c));
}
{
public NotTriangleException()
: base("The triangle is not right")
{ }
}
static double Square(double a, double b, double c)
{
if (Math.Abs(a-b) > c || a+b < c)
throw new NotTriangleException();
var p = (a+b+c) / 2;
return Math.Sqrt(p * (p-a) * (p-b) * (p-c));
}
{
public NotTriangleException(Exception innerException)
: base("", innerException)
{
}
}
static double Square(double a, double b, double c)
{
bool aCriteria = a < b + c;
bool bCriteria = b < a + c;
bool cCriteria = c < b + a;
if (!aCriteria || !bCriteria || !cCriteria)
{
throw new NotTriangleException(new ArgumentException());
}
double p = a + b + c;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
{
if (a + b < c || b + c < a || a + c < b)
throw new NotTriangleException();
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public class NotTriangleException : Exception { }
static double Square(double a, double b, double c)
{
if (a + b < c || a + c < b || b + c < a)
throw new NotTriangleException();
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
static double Square(double a, double b, double c)
{
if(a+b < c || a+c < b || b+c < a)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
{
if (a + b < c ||
a + c < b ||
b + c < a) throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
class NotTriangleException : Exception { }
{
}
static double Square(double a, double b, double c)
{
if(a < b + c && b < a + c && c < a + b)
{
return Math.Pow((a + b + c) * (b + c - a) * (a + c - b) * (a + b - c), 0.5) * 0.25;
}
throw new NotTriangleException();
}
public NotTriangleException(string message) : base(message) { }
}
static double Square(double a, double b, double c) {
if(!(a + b > c && a + c > b && b + c > a))
throw new NotTriangleException("Не трикутник");
double p = (a+b+c)/2;
return Math.Sqrt(p*(p-a)*(p-b)*(p-c));
}
static double Square(double a, double b, double c)
{
if (a + b < c || a + c < b || b + c < a)
throw new NotTriangleException();
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
{
if (a + b < c || a + c < b || b + c < a) throw new NotTriangleException();
double semiperimeter = (a + b + c) / 2;
return Math.Sqrt(semiperimeter * (semiperimeter - a) * (semiperimeter - b) * (semiperimeter - c));
}
class NotTriangleException : Exception
{
public NotTriangleException() : base("")
{ }
}
{
public NotTriangleException()
: base("There is no triangle with such sides.")
{ }
}
static double Square(double a, double b, double c)
{
if (!(c < a + b && b < a + c && a < b + c))
{
throw new NotTriangleException();
}
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
{
public NotTriangleException() :base(){}
}
static void CheckIfTraingle(double a, double b, double c)
{
if((a+b) < c || (a+c) < b || (b+c) < a)
throw new NotTriangleException();
}
public static double Square(double a, double b, double c)
{
CheckIfTraingle(a,b,c);
double p = (a + b + c) / 2;
return Math.Sqrt(p*(p - a) + p*(p -b) + p*(p - c));
}
{
}
static double Square(double a, double b, double c)
{
return a + b > c || a + c > b || c + b > a ?
Math.Pow(((a + b + c) / 3) * (((a + b + c) / 3) - a) * (((a + b + c) / 3) - b) * (((a + b + c) / 3) - c), 0.5)
: throw new NotTriangleException();
}
public static double Square(double a, double b, double c) {
if (a + b > c && a + c > b && b + c > a)
return Math.Sqrt((a + b + c) * (b + c) * (c + a) * (a + b));
else
throw new NotTriangleException();
}
public NotTriangleException():base(){}
}
static double Square(double a, double b, double c) {
if(a+b<=c ||a+c<=b || b+c<=a)
throw new NotTriangleException();
double p=(a+b+c)/2;
return Math.Sqrt(p*(p - a)*(p - b)*(p - c));
}