#include <iostream>
#include <cmath>
using namespace std;
class Triangle
{
public:
Triangle();
float perimeter(void);
float area(void);
void showMessage();
Triangle(float x,float y,float z);
private:
float a,b,c;
};
void main()
{
Triangle Tri1;
Tri1.showMessage();
Triangle Tri2(7,8,9);
Tri2.showMessage();
}
float Triangle::perimeter(void)
{
return (a+b+c);
}
float Triangle::area(void)
{
float s,m;
s=(a+b+c)/2;
m=sqrt(s*(s-a)*(s-b)*(s-c));
return m;
}
void Triangle::showMessage()
{
cout<<"三角形的三边为: "<<a<<'\t'<<b<<'\t'<<c<<endl;
cout<<"该三角形的周长为:"<<perimeter()<<'\t'<<"面积为:"<<area()<<endl;
}
Triangle::Triangle(float x,float y,float z)
{
a=x;
b=y;
c=z;
}
Triangle::Triangle()
{
a=1;
b=1;
c=1;
}