C语言从键盘上输入一个梯形的上底a、下底b和高h,输出梯形的面积。

#include<stdio.h>

int main()

{

 double a, b, h, s;//定义变量,上底,下底,高,面积

 scanf_s("%lf,%lf,%lf", &a, &b, &h);//输入

 s = (a + b) * h / 2.0;//计算面积

 printf("%lf", s);//输出面积

 return 0;

}

 

posted @ 2023-05-21 22:07  放氮气的蜗牛  阅读(166)  评论(0编辑  收藏  举报  来源