fork download
  1. //課題012
  2. //これは上底と下底と高さから台形の面積を表示するプログラムです
  3. // 2026.06.10 24A2021 伊藤宗兼
  4. #include <stdio.h>
  5.  
  6. int main(void) {
  7. int upperbase; //上底
  8. int bottombase; //下底
  9. int height; //高さ
  10. int area; //面積
  11.  
  12. scanf("%d", &upperbase);
  13. scanf("%d", &bottombase);
  14. scanf("%d", &height);
  15.  
  16. area = ((upperbase + bottombase) * height) / 2;
  17. printf("上底が%d、下底が%d、高さが%dの面積は%dです。¥n",upperbase, bottombase, height, area);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5320KB
stdin
1
2
3
stdout
上底が1、下底が2、高さが3の面積は4です。¥n