個人相片
幫我看看這個不聽話的選單吧
資研的玟逸兒 李發表於2014年 10月 25日(六.) 19:52
#include <iostream>
#include <cmath>
#include<cstdlib>
#define PI 3.14159
using namespace std;

int main()

    double triangle , circle , rectangle ;
    double a, b, r, e, f;
    int c;
   
   
       
   

    cout <<"若要計算三角形的面積,請輸入1" << endl;
    cout <<"若要計算圓形的面積,請輸入2"  << endl;
    cout <<"若要計算矩形的面積,請輸入3"  << endl;
   
    cin >> c;
 
  if (c==1){
 
       
        cout<<"請輸入三角形的底和高"<<endl;
        cin>> a,b;
        triangle =a*b/2 ;
        cout << triangle;
  }
 
  else if (c==2){
     
        cin>>r;
        cout <<"請輸入圓形的半徑"<< endl;
        circle=r*r*PI;
        cout <<"面積為"<< circle << endl;
  }
  else if (c==3){ 
     
        cin>>e,f;
        cout <<"請輸入長和寬"<<endl;
        rectangle=e*f;
        cout << "面積為"<< rectangle << endl;
  }
 
  system("pause");
  return 0;
}