Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:用递归,这道题超时啊,怎么解决,求助~~In Reply To:用递归,这道题超时啊,怎么解决,求助~~ Posted by:1120101780 at 2011-07-06 16:24:14 > #include<stdio.h> > int fa(int n) > { > int m; > if(n==1) > m=2; > else > if(n==2) > m=3; > else m=fa(n-1)+fa(n-2); > return(m); > } > > void main() > { > int i,j,m,n,p; > scanf("%d",&n); > for(i=0;i<n;i++) > { > scanf("%d",&m); > p=fa(m); > printf("Scenario #%d:\n%d\n",i+1,p); > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator