int high = Convert.ToInt32(Console.ReadLine());
double zong = 0;//zong为一共经过的距离
int cishu = 1; //cishu为第几次落地
double tiao = high;//tiao为反弹高度
do { zong+=tiao*2; cishu++; tiao/=2;
if (cishu == 4)
{
Console.WriteLine("反弹高度为" + tiao);
}
} while (cishu <= 3);
Console.WriteLine(zong-high);
方法二:
int n = Convert.ToInt32(Console.ReadLine());
double high = n;
int i = 1;
double sum = high;
do
{ high = high / 2;
i++;
sum += (2 * high);}
while (i < 11);
Console.WriteLine("落地高度" + high);
Console.WriteLine("和" + sum);