#include<iostream.h>
double Area(float r);
double Area(float a, float b);
double Perimeter(float r);
double Perimeter(float a, float b);
void main()
{
cout<<"请选择需要输入的非负数个数:1或2\t";
int n;
cin>>n;
float x = 0,y = 0;
if(n==2)
{
cout<<"请输入这两个非负数:"<<endl;
cin>>x;
cin>>y;
cout<<"这个矩形的周长是:"<<Perimeter(x,y)<<endl;
cout<<"这个矩形的面积是:"<<Area(x,y)<<endl;
}
else if(n==1)
{
cout<<"请输入这一个非负数:"<<endl;
cin>>x;
cout<<"这个圆的周长是:"<<Perimeter(x)<<endl;
cout<<"这个圆的面积是:"<<Area(x)<<endl;
}
else
{
cout<<"输入错误!退出程序!"<<endl;
}
}
double Area(float r)
{
return (3.14 * r * r);
}
double Area(float a, float b)
{
return (a * b);
}
double Perimeter(float r)
{
return (2 * 3.14 * r);
}
double Perimeter(float a, float b)
{
return (2 * (a + b));
}