猴子第1天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了的。第2天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,就只剩一个桃子了。求第1天共摘多少个桃子。
#include<stdio.h>
int main()
{
int peaches = 1;
for (int day = 9;day >= 1;day--)
{
peaches = (peaches + 1) * 2;
}
printf("第一天共摘%d个桃子\n", peaches);
return 0;
}
618

被折叠的 条评论
为什么被折叠?



