Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2509532
  • 博文数量: 308
  • 博客积分: 5547
  • 博客等级: 大校
  • 技术积分: 3782
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 09:47
个人简介

hello world.

文章分类

全部博文(308)

分类: C/C++

2010-07-26 17:22:30

    题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
    分析这道题,可以知道,第一次反弹的是整个高度的一半,第二次是源高度的一半的一半,依次类推。代码如下:

#include <stdio.h>

int main(int argc,int *argv[])
{
    float n = 100.0,temp;
    float all = 0;
    int count=1;
    temp = n;
    all += n;
    do
    {
      temp = temp /2;
      all += temp * 2;
      count ++;
    } while (count <= 10);
    printf("the all length:%f,the 10 length:%f",all,temp);
    system("pause");
    return 0;
}


阅读(1453) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~