C 练习实例20 - 小球自由下落

C 语言教程 · 2019-02-21 16:56:29

题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?

程序分析:见下面注释。

程序源代码:

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include<stdio.h> int main() { float h,s; h=s=100; h=h/2; //第一次反弹高度 for(int i=2;i<=10;i++) { s=s+2*h; h=h/2; } printf("第10次落地时,共经过%f米,第10次反弹高%f米\n",s,h); return 0; }

以上实例输出结果为:

第10次落地时,共经过299.609375米,第10次反弹高0.097656米

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

Python Data Structures and Algorithms

Python Data Structures and Algorithms

Benjamin Baka / Packt Publishing / 2017-5-30 / USD 44.99

Key Features A step by step guide, which will provide you with a thorough discussion on the analysis and design of fundamental Python data structures.Get a better understanding of advanced Python c......一起来看看 《Python Data Structures and Algorithms》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码