C语言 while循环 一球从100米高度自由落下,每次落地后反跳回原高度的一半

2025-03-25 22:37:14
推荐回答(1个)
回答1:

main() 

float sn=100.0,hn=sn/2; 
int n; 
for(n=2;n<=10;n++) 
 { 
  sn=sn+2*hn;/*第n次落地时共经过的米数*/ 
  hn=hn/2; /*第n次反跳高度*/ 
 } 
printf("the total of road is %f\n",sn); 
printf("the tenth is %f meter\n",hn); 
}