#include <cstdlib>
#include <iostream>
#include <cmath>
#define pi 3.1415926
using namespace std;
int main(int argc, char *argv[])
{
cout << "若要計算三角形面積請輸入1,圓形面積請輸入2,矩形面積請輸入3"<< endl;
double area , x, a, b, c, s;
cin>> x;
if (x==1)
{
cin >> a;
cin >> b;
cin >> c;
s=(a+b+c)/2 ;
area=sqrt(s*(s-a)*(s-b)*(s-c)) ;
cout << area << endl;
}
else if (x==2)
{
cin >> a;
area=a*a*pi ;
cout << area << endl;
}
else if (x==3)
{
cin >> a;
cin >> b;
area=a*b ;
cout << area << endl;
}
system ("pause");
return 0 ;
} |