返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int area(double ground,double height)
  5. {
  6.     return ground*height/2;
  7. }
  8. int area(double side)
  9. {
  10.     return side*side;
  11. }
  12. int area(double top,double ground,double height)
  13. {
  14.     return (top+ground)*height/2;
  15. }
  16. int main()
  17. {
  18.     int select;
  19.     cout<<"(1)三角形(2)正方形(3)梯形:";
  20.     cin>>select;
  21.     if(select==1)
  22.     {
  23.         double ground,height;
  24.         cin>>ground;
  25.         cin>>height;
  26.         cout<<area(ground,height);
  27.     }
  28.     if(select==2)
  29.     {
  30.         double side;
  31.         cin>>side;
  32.         cout<<area(side);
  33.     }
  34.     if(select==3)
  35.     {
  36.         double top,ground,height;
  37.         cin>>top;
  38.         cin>>ground;
  39.         cin>>height;
  40.         cout<<area(top,ground,height);
  41.     }
  42.     system("pause");
  43.     return 0;
  44. }
複製代碼

TOP

返回列表