问题:
一只猴子摘了一些桃子,第一天吃了其中的一半然后又吃了一个,以后照此方法,直到第10天早上,猴子发现只剩下一个桃子,问猴子第一天摘了多桃子。
#include <stdio.h>
#include <stdlib.h>
int A(int n);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
printf("第一天有%d个桃子.\n", A(0));
return 0;
}
int A(int n)
{
if(n>=9)
return 1;
else
return (2*(A(n+1)+1));
}
原文地址:http://blog.csdn.net/orangeisnotapple/article/details/44871699