#include
#include #include
using namespace std;
double St(double x1, double y1, double x2, double y2)
{
return sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
}
double Per(double a, double b, double c)
{
return a+b+c;
}
double S(double a, double b, double c)
{
double p2 = Per(a,b,c)/2;
return sqrt(p2*(p2-a)*(p2-b)*(p2-c));
}
int main()
{
double x1, y1, x2, y2, x3, y3;
double a, b, c, p, s;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> x3 >> y3;
a = St(x1,y1,x2,y2);
b = St(x1,y1,x3,y3);
c = St(x2,y2,x3,y3);
p = Per(a,b,c);
s = S(a,b,c);
cout.setf(std::ios::fixed);
cout.precision(6);
cout << "p = " << p << "\n";<br> cout << "s = " << s << "\n";<br> system("Pause");
return 0;
}
Пример:
1 1
4 1
1 5
p = 12.000000
s = 6.000000