/* Note:Your choice is C IDE */ #include "stdio.h" void main() { float sn=100.0,hn=sn/2; int n; n=2; do { sn=sn+2*hn; hn=hn/2; n++; }while(n<=10); printf("第十次落地时,共经过%f米\n\n",sn); printf("第十次反弹的高度, %f米\n\n",hn); sn=100.0; hn=sn/2; n=2; while(n<=10) { sn=sn+2*hn; hn=hn/2; n++; } printf("第十次落地时,共经过%f米\n",sn); printf("第十次反弹的高度, %f米\n\n",hn); sn=100.0; hn=sn/2; n=2; for(;n<=10;) { sn=sn+2*hn; hn=hn/2; n++; } printf("第十次落地时,共经过%f米\n",sn); printf("第十次反弹的高度, %f米\n\n",hn); }
归去来兮