/*总和模型为:hight+hight/2, (hight/2+ hight/2/2), (hight/2/2+hight/2/2/2),....*/
#include<iostream>
using namespace std;
float rebound(float hight, int count)
{
if(count==1) return hight/2;
return rebound( hight, count-1)/2;
}
float sum_rebound(float hight, int count)
{
if(count==1) return hight*3.0/2.0;
return sum_rebound( hight, count-1)+rebound( hight, count-1)+rebound( hight, count-1)/2.0;
}
int main()
{
cout<<"此次的反弹高度"<<rebound(100.0, 3)<<endl;
cout<<"此次的反弹累积总高度"<<sum_rebound(100.0, 3)<<endl;
return 0;
}