偶用循环方式做了一个:#include<stdio.h>
int main(){ int i,sum; for(sum = 1, i = 9; i >= 1; i --) sum = 2 * (sum + 1); printf("first day ... = %d\n", sum); return 0;}
也可以用递归方式做:#include<stdio.h>
int tao(int n){ if (n == 1) return 1; else return 2*(tao( n - 1) + 1);}
int main(){ printf("First day ..... is %d.\n", tao(10)); return 0;}
[此贴子已经被作者于2007-1-27 0:35:47编辑过]