異なる数字に基づいて、異なる図形の面積を出力します.

1227 ワード

 
 


 

/*
 * Copyright (c) 2013,
* All rights reserved.
*     : 
* :2013   11 11
* :v1.0
*
* :
* : ,
* :
* :
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{

 

int num;

double  h,a,b,c,s,r;

cout<<"1. "<<"   "<<"2. "<<"   "<<"3. ";
cin>>num;

if(num==1)
{
cout<<" a b:";
cin>>a>>b;
s=a*b;
cout<<"s="<<s<<endl;
}
else if(num==2)
{
cout<<" c h:";
cin>>c>>h;
s=(c*h)/2;
cout<<"s="<<s<<endl;
}
else if(num==3)
{
cout<<" r:";
cin>>r;
const double PI=3.1415;
s=PI*r*r;
cout<<"s="<<s<<endl;
}
else
cout<<" : ";
return 0;


}