![]() |
#2
yuccn2013-03-15 22:19
|
#include <iostream>
using namespace std;
const float PI=3.1416;
float r,a,b,c,s;
int main()
{
int i;
cout<<"圆形1,长方形2,正方形3:";
cin>>i;
switch(i)
{
case 1:
cout<<"圆形的半径为:"
cin>>r;
s=PI*r*r;
cout<<"圆形的面积为:"<<s<<endl;
break;
case 2:
cout<<长方形的长为:"
cin>>a;
cout<<长方形的宽为:"
cin>>b;
s=a*b;
cout<<"长方形的面积为:"<<s<<endl;
break;
case 3:
cout<<正方形的边长为:"
cin>>c;
s=c*c;
cout<<"正方形的面积为:"<<s<<endl;
break;
default:
cout<<s<<endl;
}
}