时间限制: 1 Sec 内存限制: 128 MB
提交: 1825 解决: 837
[提交][状态][讨论版]

题目描述

一个物体从100米的高空自由落下。编写程序,求它在前3秒内下落的垂直距离。设重力加速度为10米/秒2。

输入

本题目没有输入。

输出

按照下列格式输出
height = 垂直距离值
结果保留2位小数。

  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(void)
  4. {
  5. double height;
  6. int t, g;
  7. t = 3;
  8. g = 10;
  9. height = g * pow(t, 2) / 2;
  10. if (height <= 100)
  11. {
  12. height = g * pow(t, 2) / 2;
  13. }
  14. else
  15. {
  16. height = 100;
  17. }
  18. printf("height = %.2f", height);
  19. return 0;
  20. }