int main()
{
int n = 35
float h = 0, drop = 5
int day = 0
while (h < n)
{
if (day != 0)
{
h -= drop //夜晚下滑drop米
drop /= 2
}
day++
h += 6 //白天爬6米
}
printf("总共需要%d天\n", day)
return 0
}
#include <stdio.h>void main(void)
{
int i=0
while((i*0.4+1)<10)i++//除去最后一次,向上爬的次数
float last=10-0.4*i//最后一次爬的距离
float total=last+i//1米需一小时,急滑0.6米认为不耗时,i代表最后一次之前所有耗费的时间
printf("The needed time is:%f hours\n",total)
}