展开全部
#include<stdio.h>
float fun(float height)
{
return height/2;
}
void main()
{
float height = 0.0;
float total = 0.0;
int count = 0;
int COUNT = 0;
printf("请输入起始高度Height(m)=");
scanf("%f", &height);
printf("请输入弹起次数COUNT=");
scanf("%d", &COUNT);
total = height;
for(count = 1; count <= COUNT; count++)
if(count < COUNT)
total += 2*(height = fun(height));
else
total += (height = fun(height));
printf("第%d次的高度是%fm\n到达该次最高点后的总路长是%fm\n", COUNT, height, total);
}
float fun(float height)
{
return height/2;
}
void main()
{
float height = 0.0;
float total = 0.0;
int count = 0;
int COUNT = 0;
printf("请输入起始高度Height(m)=");
scanf("%f", &height);
printf("请输入弹起次数COUNT=");
scanf("%d", &COUNT);
total = height;
for(count = 1; count <= COUNT; count++)
if(count < COUNT)
total += 2*(height = fun(height));
else
total += (height = fun(height));
printf("第%d次的高度是%fm\n到达该次最高点后的总路长是%fm\n", COUNT, height, total);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |