/*
***************************************************************
一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?
**************************************************************** */
#import <Foundation/Foundation.h>
int main( int argc, const char * argv[]) {
@autoreleasepool {
float hh= 100,bh,licheng= 0;
for ( int i= 1; i<= 10; i++) {
bh=hh/ 2.0;
licheng=licheng+bh+hh; // 一个来回就是hh+bh
hh=hh/ 2.0;
// printf("licheng is:%f\n",licheng);
}
printf( " licheng is:%f\n ",licheng);
return 0;
}
}
一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?
**************************************************************** */
#import <Foundation/Foundation.h>
int main( int argc, const char * argv[]) {
@autoreleasepool {
float hh= 100,bh,licheng= 0;
for ( int i= 1; i<= 10; i++) {
bh=hh/ 2.0;
licheng=licheng+bh+hh; // 一个来回就是hh+bh
hh=hh/ 2.0;
// printf("licheng is:%f\n",licheng);
}
printf( " licheng is:%f\n ",licheng);
return 0;
}
}
执行结果: