第1个回答 2015-10-23
#include <iostream>
using namespace std;
double area(double a, double b, double h)
{
return 0.5*(a+b)*h ;// 二分之一 上底加下底的和 乘以高
}
int main(void)
{
double a,b,h;
printf("请输入梯形的长、宽和高:");
scanf("%lf%lf%lf",&a,&b,&h);
printf("the length=%f,the width=%f,the height=%f\nThe area=%f\n",a,b,h,area(a,b,h));
return 0;
}
第2个回答 2015-10-23
#include<iostream>
using namespace std;
int main(){
float a,b,h,s;
cout<<"请输入长,宽,高"<<endl;
cin>>a>>b>>h;
s=(a+b)*h/2;
cout<<"梯形的面积为"<<s<<endl;
return 0;
}本回答被提问者采纳