首页 > 试题广场 >

求梯形的面积

[问答题]

求梯形的面积

内容:

已知上底、下底和高,求梯形的面积

输入说明:

一行三个数

输出说明:

一行一个数(保留2位小数)

输入样例:

3 5 4

输出样例:

16.00

例程:

#include <cstdio>
#include <iostream>
Using namespace std;
int main()
{
float a,b,c,d;
scanf("%f%f%f",&a,&b,&c);
d=(a+b)*1.0*c/2;
printf("%0.2f",d);
return 0;
} 

include

include

using namespace std;
int mian()
{
float a, b, c, d;
while(scanf("%lf%lf%lf", &a, %b, %c) != EOF)
{
d = (a + b) * c *1.0 /2.0;
printf("%0.2f", d);
}
return 0;
}

发表于 2020-08-08 13:38:34 回复(0)
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    double a, b, h;
    double res;
    while(scanf("%lf%lf%lf", &a, &b, &h) != EOF) {
        res = (a + b) * h * 1.0 / 2.0;
        printf("%.2lf\n", res);
    }
    return 0;
}

发表于 2019-11-12 17:24:37 回复(0)
#include<stdio.h>
int main()
{
    float a,b,c,v;
    printf("input three numbers(分别为长宽高)用空格隔开:");
    scanf("%f %f %f",&a,&b,&c);
    
    v = (a + b)*c/2;
    printf("output v :%0.2f\n",v);
    

    return 0;
}

发表于 2019-11-11 18:57:51 回复(0)