帮忙在程序旁边作解释,谢谢!
#include<iostream>using namespace std;
double sn=100;
int main(){
void height(double& hn,int i);
double hn=100;
int i=1;
height(hn,i);
hn=hn/2;
cout<<"第十次反弹的高度为:"<<hn<<endl;
return 0;
}
void height(double& hn,int i){
hn=hn/2;
sn=sn+2*hn;
i++;
if(i==10){
cout<<"第十次落地时经历的路程为:"<<sn<<endl;
return;
}
if(i<10){
height(hn,i);
}
}
帮忙分析程序运行过程,谢谢!