用Turbo C程序为我编以下一个题目 速度拉~~

来源:百度知道 编辑:UC知道 时间:2024/06/21 08:42:44
猴子吃桃子,第一天,它吃了整棵树的2/3,并多吃一个,然后依次类推......到第五天只有一个桃子,问总共有多少个桃子? 是用Turbo C拉 速度哦~ 谢谢大家了

#include "stdio.h"
main()
{ int i,re,totle;
totle=re=3;
do
{re=totle;
for(i=1;i<=5;i++)
re-=((2*re)/3+1);
totle++;
}while(re!=1);
totle--;
printf("%d",totle);
getch();
}

连这个都不会????

笨。。。。

#include <stdio.h>
void main(){
int i,rest,lastrest;
rest=1;
lastrest=0;
for(i=1;i<5;++i){
lastrest=3/2*(rest+1);
rest=lastrest;
}
printf("一共有 %d ",rest);
}