- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int area(double ground,double height)
- {
- return ground*height/2;
- }
- int area(double side)
- {
- return side*side;
- }
- int area(double top,double ground,double height)
- {
- return (top+ground)*height/2;
- }
- int main()
- {
- int select;
- cout<<"(1)三角形(2)正方形(3)梯形:";
- cin>>select;
- if(select==1)
- {
- double ground,height;
- cin>>ground;
- cin>>height;
- cout<<area(ground,height);
- }
- if(select==2)
- {
- double side;
- cin>>side;
- cout<<area(side);
- }
- if(select==3)
- {
- double top,ground,height;
- cin>>top;
- cin>>ground;
- cin>>height;
- cout<<area(top,ground,height);
- }
- system("pause");
- return 0;
- }
複製代碼 |