#include<iostream>
#include<cmath>
using namespace std;
class TRI
{
private:
double a, b, c;
public:
TRI(double, double, double);
double sqroot(double);
double farea();
void print();
};
TRI::TRI(double x = 1, double y = 1, double z = 1)
{
a = x;
b = y;
c = z;
}
double TRI::sqroot(double m)
{
double result = 0.1;
while (abs(result*result - m) > 1e-5)
{
int temp = m / result;
result = (temp + result) / 2;
}
return result;
}
double TRI::farea()
{
double s = (a + b + c) / 2;
return sqroot(s*(s - a)*(s - b)*(s - c));
}
void TRI::print()
{
cout << "三边分别为" << a << "\t" << b << '\t' << c << endl;
cout << "面积为" << farea() << endl;
}
int main()
{
TRI tri(3, 4, 5);
tri.print();
system("pause");
return 0;
}