Zadacha Triugulnik
Zadacha Triugulnik
Zadacha Triugulnik
namespace domMat
{
class Program
{
static void Main(string[] args)
{
Triangle1 t = new Triangle1(3, 4, 5);
Console.WriteLine("Perimeter: {0}\nFace: {1}\n", t.Perimeter(),
t.Face());
namespace domMat
{
interface ITriangle
{
double Perimeter();
double Face();
}
}
***********************************************************************************
*******
using System;
using System.Collections.Generic;
using System.Text;
namespace domMat
{
class Triangle1 : ITriangle
{
private double a;
private double b;
private double c;
public Triangle1(int a, int b, int c)
{
this.a = a;
this.b = b;
this.c = c;
}
public double Perimeter()
{
return a + b + c;
}
public double Face()
{
double p = this.Perimeter() / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
}
}
***********************************************************************************
*******
using System;
using System.Collections.Generic;
using System.Text;
namespace domMat
{
class Triangle2 : ITriangle
{
private double a;
private double b;
private double BACangle;
public Triangle2(double a, double b,double BACangle)
{
this.a = a;
this.b = b;
this.BACangle = BACangle;
}
public double Face()
{
return a * b * Math.Sin(BACangle) / 2;
}
public double Perimeter()
{
double h = b * Math.Sin(BACangle);
double a1 = Math.Sqrt(Math.Pow(b, 2) - Math.Pow(h, 2));
double a2 = a - a1;
double c = Math.Sqrt(Math.Pow(a2, 2) + Math.Pow(h, 2));
return a + b + c;
}
}
}