#include <iostream>
#include <cmath>
using namespace std;
class Triangle
{
public:
float perimeter(void);
float area(void);
void showMessage();
Triangle(float x=1,float y=2,float z=2);
private:
float a,b,c;
};
void main()
{
Triangle Tri1;
Tri1.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;
}