#include<iostream>
#include<cmath>
using namespace std;
#define PI 3.1415926f
float area(float );
float area(float ,float,int);
float area(float ,float ,float );
int main()
{
float a=3,b=5;
cout<<"三角形:"<<area(a,b,3)<<endl;
cout<<"长方形:"<<area(a,b,4)<<endl;
cout<<"圆:"<<area(a)<<endl;
cout<<"梯形:"<<area(a,b,a)<<endl;
return 0;
}
float area(float width,float height,int side)
{
if(side==4)
return width*height;
return width*height/2;
}
float area(float radius)
{
return PI*pow(radius,2);
}
float area(float upside,float downside,float height)
{
return (upside+downside)*height/2;
}
温馨提示:答案为网友推荐,仅供参考