正在加载图片...
法二:用函数的递归调用求解 第8章第6节 前一天的桃子数=(后一天的桃子数+1)×2 (1)=(x(2)+1)*2 X(2)=(x(3)+1)2 当n=10 2*(x(n+1)+1) x(9)=(x(10)+1)*2 程序 int x(int n) if(n=10)c=1; else c=2*(x(n+1)+1); return(c): 1 main( Rint b int x(int); 函数声明(可省略) 函数调用 printf(“ resulte=%dn”,b);法二:用函数的递归调用求解 前一天的桃子数=(后一天的桃子数+1)×2 x(1)=(x(2)+1)*2 x(2)=(x(3)+1)*2 ..... x(9)=(x(10)+1)*2 1 x(n) =1 =2*(x(n+1)+1) 当n=10 int x(int n) {int c; if(n==10) c=1; else c=2*(x(n+1)+1); return(c);} main() {int b; int x(int); b=x(1); printf(“resulte=%d\n”,b); } 第8章第6节 函数声明(可省略) 函数调用 程序
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有