int peach_num = 1;//第十天桃子数量
int day = 10;//一共吃了10天,因为10在后面需要用到,所以定义到for外边
for (; day>1; day--) {
printf("第%d天,peach_num = %d\n", day,peach_num);
peach_num = (peach_num + 1) * 2;//前一天都是今天桃子数量+1,乘以2
}
printf("第%d天,peach_num = %d\n", day,peach_num);
return 0;
哪里不懂下个断点,查看执行过程。 |