/*
***************************************************************
一球從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;
}
}
執行結果:
