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 |
用递归,这道题超时啊,怎么解决,求助~~#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